Skip to content

Commit eab1d70

Browse files
committed
net mon UPDATE additional rc checks
1 parent a0c525c commit eab1d70

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/netconf_monitoring.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ np_getschema_print_yang(const struct lys_module *mod, const struct lysp_submodul
482482
goto cleanup;
483483
}
484484
len = ftell(f);
485+
if (len == -1) {
486+
asprintf(&msg, "Failed to ftell in \"%s\" (%s).", filepath, strerror(errno));
487+
reply = np_reply_err_op_failed(NULL, ctx, msg);
488+
free(msg);
489+
goto cleanup;
490+
}
485491
fseek(f, 0, SEEK_SET);
486492

487493
/* read the data */
@@ -490,7 +496,12 @@ np_getschema_print_yang(const struct lys_module *mod, const struct lysp_submodul
490496
reply = np_reply_err_op_failed(NULL, ctx, "Memory allocation failed.");
491497
goto cleanup;
492498
}
493-
fread(*yang_data, 1, len, f);
499+
if (fread(*yang_data, 1, len, f) != (unsigned)len) {
500+
asprintf(&msg, "Failed to read from \"%s\" (%s).", filepath, strerror(errno));
501+
reply = np_reply_err_op_failed(NULL, ctx, msg);
502+
free(msg);
503+
goto cleanup;
504+
}
494505
(*yang_data)[len] = '\0';
495506

496507
cleanup:

0 commit comments

Comments
 (0)