wmifs: Error handling when fopen fails.

This prevents fgets from segfaulting on the next line, closing Debian
bug #901353.

Thanks to <anomie@users.sourceforge.net> for the bug report and patch.
This commit is contained in:
Doug Torrance 2018-06-27 18:09:12 -04:00 committed by Carlos R. Mafra
parent 8b31ced398
commit b03c910dc2

View file

@ -764,6 +764,8 @@ int get_statistics(char *devname, long *ip, long *op, long *is, long *os)
/* Read from /proc/net/dev the stats! */ /* Read from /proc/net/dev the stats! */
fp = fopen("/proc/net/dev", "r"); fp = fopen("/proc/net/dev", "r");
if (!fp)
return -1
if (!fgets(temp, BUFFER_SIZE, fp)) { if (!fgets(temp, BUFFER_SIZE, fp)) {
fclose(fp); fclose(fp);
return -1; return -1;