Date: Fri, 23 Oct 2015 19:28:25 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289845 - head/sbin/savecore Message-ID: <201510231928.t9NJSPqA086495@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Fri Oct 23 19:28:24 2015 New Revision: 289845 URL: https://svnweb.freebsd.org/changeset/base/289845 Log: 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 Modified: head/sbin/savecore/savecore.c Modified: head/sbin/savecore/savecore.c ============================================================================== --- head/sbin/savecore/savecore.c Fri Oct 23 19:28:15 2015 (r289844) +++ head/sbin/savecore/savecore.c Fri Oct 23 19:28:24 2015 (r289845) @@ -606,7 +606,8 @@ DoFile(const char *savedir, const char * } 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 * 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 * 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"); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510231928.t9NJSPqA086495>