Browse Source

Check fread return value

Jouni Malinen 15 years ago
parent
commit
a698d28415
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/utils/os_internal.c

+ 6 - 1
src/utils/os_internal.c

@@ -206,7 +206,12 @@ char * os_readfile(const char *name, size_t *len)
 		return NULL;
 	}
 
-	fread(buf, 1, *len, f);
+	if (fread(buf, 1, *len, f) != *len) {
+		fclose(f);
+		os_free(buf);
+		return NULL;
+	}
+
 	fclose(f);
 
 	return buf;