From: guenther Date: Sun, 26 Apr 2015 01:23:19 +0000 (+0000) Subject: Fix glitches in previous commit: strip the \n and only complain on failure X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ccc73f79b0869afbb2bbe200544b35188f5f29c9;p=openbsd Fix glitches in previous commit: strip the \n and only complain on failure ok deraadt@ --- 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); }