Date: Wed, 17 Sep 2014 19:09:58 +0000 (UTC) From: Bryan Drewery <bdrewery@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r271720 - head/sbin/savecore Message-ID: <201409171909.s8HJ9wgv017141@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdrewery Date: Wed Sep 17 19:09:58 2014 New Revision: 271720 URL: http://svnweb.freebsd.org/changeset/base/271720 Log: If fgets(3) fails in getbounds(), show strerror(3) if not an EOF. Also fix a FILE* leak in getbounds(). Submitted by: Conrad Meyer <conrad.meyer@isilon.com> PR: 192032 Sponsored by: EMC / Isilon Storage Division MFC after: 1 week Modified: head/sbin/savecore/savecore.c Modified: head/sbin/savecore/savecore.c ============================================================================== --- head/sbin/savecore/savecore.c Wed Sep 17 19:01:22 2014 (r271719) +++ head/sbin/savecore/savecore.c Wed Sep 17 19:09:58 2014 (r271720) @@ -151,7 +151,10 @@ getbounds(void) { } if (fgets(buf, sizeof buf, fp) == NULL) { - syslog(LOG_WARNING, "unable to read from bounds, using 0"); + if (feof(fp)) + syslog(LOG_WARNING, "bounds file is empty, using 0"); + else + syslog(LOG_WARNING, "bounds file: %s", strerror(errno)); fclose(fp); return (ret); } @@ -160,6 +163,7 @@ getbounds(void) { ret = (int)strtol(buf, NULL, 10); if (ret == 0 && (errno == EINVAL || errno == ERANGE)) syslog(LOG_WARNING, "invalid value found in bounds, using 0"); + fclose(fp); return (ret); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201409171909.s8HJ9wgv017141>