summaryrefslogtreecommitdiffstats
path: root/sbin/savecore
diff options
context:
space:
mode:
authorbdrewery <bdrewery@FreeBSD.org>2014-09-17 19:09:58 +0000
committerbdrewery <bdrewery@FreeBSD.org>2014-09-17 19:09:58 +0000
commit3f85fc738777b1cad36b3c944798d3f173ba1d58 (patch)
tree60dcbd54909d2a8b5d27d7b69c2269a3e207fa89 /sbin/savecore
parent4044c8d29de600d2b94a48da1b111a18c3f0c0f8 (diff)
downloadFreeBSD-src-3f85fc738777b1cad36b3c944798d3f173ba1d58.zip
FreeBSD-src-3f85fc738777b1cad36b3c944798d3f173ba1d58.tar.gz
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
Diffstat (limited to 'sbin/savecore')
-rw-r--r--sbin/savecore/savecore.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 0f1d41e..7a5fc4c 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -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);
}
OpenPOWER on IntegriCloud