From owner-svn-src-all@freebsd.org Fri Nov 6 19:18:22 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44226A28A39; Fri, 6 Nov 2015 19:18:22 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FFFD1FD9; Fri, 6 Nov 2015 19:18:21 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA6JILhH025058; Fri, 6 Nov 2015 19:18:21 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA6JILbL025057; Fri, 6 Nov 2015 19:18:21 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201511061918.tA6JILbL025057@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 6 Nov 2015 19:18:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r290463 - head/sbin/savecore X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Nov 2015 19:18:22 -0000 Author: asomers Date: Fri Nov 6 19:18:20 2015 New Revision: 290463 URL: https://svnweb.freebsd.org/changeset/base/290463 Log: Always check the return value of lseek. This is a follow-up to r289845, which only fixed one occurence of CID 1009429. Coverity CID: 1009429 Reviewed by: markj MFC after: 2 weeks X-MFC-With: r289845 Sponsored by: Spectra Logic Differential Revision: https://reviews.freebsd.org/D4096 Modified: head/sbin/savecore/savecore.c Modified: head/sbin/savecore/savecore.c ============================================================================== --- head/sbin/savecore/savecore.c Fri Nov 6 18:50:01 2015 (r290462) +++ head/sbin/savecore/savecore.c Fri Nov 6 19:18:20 2015 (r290463) @@ -491,9 +491,8 @@ DoFile(const char *savedir, const char * } lasthd = mediasize - sectorsize; - lseek(fd, lasthd, SEEK_SET); - error = read(fd, &kdhl, sizeof kdhl); - if (error != sizeof kdhl) { + if (lseek(fd, lasthd, SEEK_SET) != lasthd || + read(fd, &kdhl, sizeof(kdhl)) != sizeof(kdhl)) { syslog(LOG_ERR, "error reading last dump header at offset %lld in %s: %m", (long long)lasthd, device); @@ -569,9 +568,8 @@ DoFile(const char *savedir, const char * } dumpsize = dtoh64(kdhl.dumplength); firsthd = lasthd - dumpsize - sizeof kdhf; - lseek(fd, firsthd, SEEK_SET); - error = read(fd, &kdhf, sizeof kdhf); - if (error != sizeof kdhf) { + if (lseek(fd, firsthd, SEEK_SET) != firsthd || + read(fd, &kdhf, sizeof(kdhf)) != sizeof(kdhf)) { syslog(LOG_ERR, "error reading first dump header at offset %lld in %s: %m", (long long)firsthd, device);