From b6858c83ec4effff0b3aa09517d873e2680b0973 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Thu, 13 Aug 2015 11:18:13 -0700 Subject: Conninit: Check fread return value Bug: 18632512 (cherry picked from commit 832524f54092092b7f2031f97609f3ff698de08c) Change-Id: I47c851e98b769d0e78e9743de1bd9af0420462a4 --- conn_init/conn_init.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 @@ static int wifi_check_qcom_cfg_files() // Read MAC String FILE *fp = NULL; - int n = 0; fp = fopen("/persist/wifi/.macaddr", "r"); if ( fp == NULL ) { @@ -38,8 +37,13 @@ static int wifi_check_qcom_cfg_files() } 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); -- cgit v1.2.3