Explorar o código

Fix warning, check if read of dialplan was OK.

AdrianSimionov %!s(int64=9) %!d(string=hai) anos
pai
achega
0c54a5f546
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      src/docsis.c

+ 6 - 1
src/docsis.c

@@ -168,6 +168,7 @@ add_dialplan (unsigned char *tlvbuf, unsigned int tlvbuflen) {
   FILE *dialplan_file;
   char *dialplan_buffer;
   unsigned int fileSize;
+  unsigned int readSize;
   unsigned short local_v_len;
   unsigned short *p_local_v_len = &local_v_len;
   unsigned short local_char;
@@ -186,7 +187,11 @@ add_dialplan (unsigned char *tlvbuf, unsigned int tlvbuflen) {
     fprintf(stderr, "Fatal error allocating memory for dialplan buffer, closing.\n");
     exit(-1);
   }
-  fread(dialplan_buffer, fileSize, 1, dialplan_file);
+  readSize = fread(dialplan_buffer, fileSize, 1, dialplan_file);
+  if (!readSize) {
+    fprintf(stderr, "Something went wrong reading the dialplan file, closing.\n");
+    exit(-1);
+  }
   fclose(dialplan_file);
 
   tlvbuflen -= 3;