summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-04-26 01:23:20 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-04-26 01:23:20 +0000
commitf54c063b9514f3b08269b4a6cfb8cd304e8b3716 (patch)
tree9a83f76507274afb695875f2bba54575ebf0928a
parent40beb2b14a6c0623dcf0bf6613dc8a20e2a8f5ab (diff)
Fix glitches in previous commit: strip the \n and only complain on failure
ok deraadt@
-rw-r--r--sbin/savecore/savecore.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 53cc2a7dac2..c4d08030612 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: savecore.c,v 1.52 2015/04/18 18:28:37 deraadt Exp $ */
+/* $OpenBSD: savecore.c,v 1.53 2015/04/26 01:23:19 guenther Exp $ */
/* $NetBSD: savecore.c,v 1.26 1996/03/18 21:16:05 leo Exp $ */
/*-
@@ -390,8 +390,11 @@ save_core(void)
err1: syslog(LOG_WARNING, "%s: %s", path, strerror(errno));
bounds = 0;
} else {
- const char *errstr;
+ const char *errstr = NULL;
+ char *p;
+ if ((p = strchr(buf, '\n')) != NULL)
+ *p = '\0';
bounds = strtonum(buf, 0, INT_MAX, &errstr);
if (errstr)
syslog(LOG_WARNING, "bounds was corrupt: %s", errstr);
@@ -613,10 +616,14 @@ check_space(void)
minfree = 0;
else {
const char *errstr;
+ char *p;
+ if ((p = strchr(buf, '\n')) != NULL)
+ *p = '\0';
minfree = strtonum(buf, 0, LLONG_MAX, &errstr);
- syslog(LOG_WARNING,
- "minfree was corrupt: %s", errstr);
+ if (errstr)
+ syslog(LOG_WARNING,
+ "minfree was corrupt: %s", errstr);
}
(void)fclose(fp);
}