summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2015-04-26 01:23:19 +0000
committerguenther <guenther@openbsd.org>2015-04-26 01:23:19 +0000
commitccc73f79b0869afbb2bbe200544b35188f5f29c9 (patch)
tree90fd10cd0ad9ca9353e27d81bba6151efc753b56
parentsome people are capitalizing keywords, so ignore case when we test the tokens (diff)
downloadwireguard-openbsd-ccc73f79b0869afbb2bbe200544b35188f5f29c9.tar.xz
wireguard-openbsd-ccc73f79b0869afbb2bbe200544b35188f5f29c9.zip
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);
}