Conninit: Check fread return value
Bug: 18632512
(cherry picked from commit 832524f54092092b7f2031f97609f3ff698de08c)
Change-Id: I47c851e98b769d0e78e9743de1bd9af0420462a4
diff --git a/conn_init/conn_init.c b/conn_init/conn_init.c
index 2cb5591..08759b5 100644
--- a/conn_init/conn_init.c
+++ b/conn_init/conn_init.c
@@ -29,7 +29,6 @@
// Read MAC String
FILE *fp = NULL;
- int n = 0;
fp = fopen("/persist/wifi/.macaddr", "r");
if ( fp == NULL )
{
@@ -38,8 +37,13 @@
}
else
{
- n = fread(macAddress, 12, 1, fp);
+ int n = fread(macAddress, 12, 1, fp);
fclose(fp);
+ if (n != 12) {
+ memset(macAddress, 0, 13);
+ wfc_util_qcom_check_config((unsigned char *)macAddress);
+ return 0;
+ }
// Write MAC String
wfc_util_atoh( macAddress, 12, (unsigned char *)hex, 6);