aboutsummaryrefslogtreecommitdiff
path: root/sbin/savecore
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2015-11-06 19:18:20 +0000
committerAlan Somers <asomers@FreeBSD.org>2015-11-06 19:18:20 +0000
commit49f1692b7834d76d9b4bf841f71f0aaa7f0d804e (patch)
tree921d8184ea24feb126acc7ce166c5c4be6c581ea /sbin/savecore
parentb94650a2bb1d46f36cd3d9715343fd24115df67b (diff)
downloadsrc-49f1692b7834d76d9b4bf841f71f0aaa7f0d804e.tar.gz
src-49f1692b7834d76d9b4bf841f71f0aaa7f0d804e.zip
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
Notes
Notes: svn path=/head/; revision=290463
Diffstat (limited to 'sbin/savecore')
-rw-r--r--sbin/savecore/savecore.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index b87b95b3276e..0c1e806e8e9d 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -491,9 +491,8 @@ DoFile(const char *savedir, const char *device)
}
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 *device)
}
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);