From: Jouni Malinen Date: Thu, 26 Feb 2009 20:06:11 +0000 (+0200) Subject: WPS UFD: Handle scandir() error and no matches results differently X-Git-Tag: hostap_0_7_0~493 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1b39bad10931fb2e5240ed1362a2b5cc79445dff;p=thirdparty%2Fhostap.git WPS UFD: Handle scandir() error and no matches results differently Better make sure there are no memory leaks in case of 0 entries found. In addition, the error string may be of use in the error case. --- diff --git a/src/wps/wps_ufd.c b/src/wps/wps_ufd.c index 56b263528..6f40c5bca 100644 --- a/src/wps/wps_ufd.c +++ b/src/wps/wps_ufd.c @@ -61,8 +61,14 @@ static int wps_get_dev_pwd_e_file_name(char *path, char *file_name) file_num = scandir(path, &namelist, &dev_pwd_e_file_filter, alphasort); - if (file_num <= 0) { + if (file_num < 0) { + wpa_printf(MSG_ERROR, "WPS: OOB file not found: %d (%s)", + errno, strerror(errno)); + return -1; + } + if (file_num == 0) { wpa_printf(MSG_ERROR, "WPS: OOB file not found"); + os_free(namelist); return -1; } os_strlcpy(file_name, namelist[0]->d_name, 13);