summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorasomers <asomers@FreeBSD.org>2015-10-23 19:28:24 +0000
committerasomers <asomers@FreeBSD.org>2015-10-23 19:28:24 +0000
commitf11412f79ebf4062cdaacff9e3aaf15e8555d72e (patch)
treea875289824e10e6530d71e326df6738f9e904ef4 /sbin
parent9545bdb16492fa66b42f7ac431cfec5437e049ca (diff)
downloadFreeBSD-src-f11412f79ebf4062cdaacff9e3aaf15e8555d72e.zip
FreeBSD-src-f11412f79ebf4062cdaacff9e3aaf15e8555d72e.tar.gz
Fix various Coverity issues in sbin/savecore/savecore.c:
CID1009429: Fix unchecked return value from lseek while clearing dump CID1007781: Fix file descriptor leak in DoFile CID1007261: Don't send potentially unterminated string to syslog(3) Coverity CID: 1009429 Coverity CID: 1007781 Coverity CID: 1007261 MFC after: 2 weeks Sponsored by: Spectra Logic Differential Revision: https://reviews.freebsd.org/D3991
Diffstat (limited to 'sbin')
-rw-r--r--sbin/savecore/savecore.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 705261f..b87b95b 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -606,7 +606,8 @@ DoFile(const char *savedir, const char *device)
}
if (kdhl.panicstring[0])
- syslog(LOG_ALERT, "reboot after panic: %s", kdhl.panicstring);
+ syslog(LOG_ALERT, "reboot after panic: %*s",
+ (int)sizeof(kdhl.panicstring), kdhl.panicstring);
else
syslog(LOG_ALERT, "reboot");
@@ -657,7 +658,7 @@ DoFile(const char *savedir, const char *device)
if (info == NULL) {
syslog(LOG_ERR, "fdopen failed: %m");
nerr++;
- goto closefd;
+ goto closeall;
}
xostyle = xo_get_style(NULL);
@@ -665,7 +666,7 @@ DoFile(const char *savedir, const char *device)
if (xoinfo == NULL) {
syslog(LOG_ERR, "%s: %m", infoname);
nerr++;
- goto closefd;
+ goto closeall;
}
xo_open_container_h(xoinfo, "crashdump");
@@ -726,9 +727,8 @@ nuke:
if (verbose)
printf("clearing dump header\n");
memcpy(kdhl.magic, KERNELDUMPMAGIC_CLEARED, sizeof kdhl.magic);
- lseek(fd, lasthd, SEEK_SET);
- error = write(fd, &kdhl, sizeof kdhl);
- if (error != sizeof kdhl)
+ if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
+ write(fd, &kdhl, sizeof(kdhl)) != sizeof(kdhl))
syslog(LOG_ERR,
"error while clearing the dump header: %m");
}
OpenPOWER on IntegriCloud