summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2010-07-15 18:23:51 +0000
committerRay Lai <ray@cvs.openbsd.org>2010-07-15 18:23:51 +0000
commita398ee5147ae37c55c9fccc5eca8fed16c499bff (patch)
tree9daf61b22f735b5988544c4aabe1b996217da5bd
parent3a81ed8efcad40bf242bf9f45c82ea48f1e2229d (diff)
Die immediately if pread fails. It's a fatal error so treat it as
such. Besides, we weren't handling the NULL being returned. From diff. Minor nit by nicm. OK xsa stsp nicm
-rw-r--r--usr.bin/cvs/diff_internals.c9
-rw-r--r--usr.bin/rcs/diff.c9
2 files changed, 6 insertions, 12 deletions
diff --git a/usr.bin/cvs/diff_internals.c b/usr.bin/cvs/diff_internals.c
index 0eaf95039ec..aa072bfb5e2 100644
--- a/usr.bin/cvs/diff_internals.c
+++ b/usr.bin/cvs/diff_internals.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff_internals.c,v 1.29 2010/07/15 11:10:23 ray Exp $ */
+/* $OpenBSD: diff_internals.c,v 1.30 2010/07/15 18:23:50 ray Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -859,11 +859,8 @@ preadline(int fd, size_t rlen, off_t off)
ssize_t nr;
line = xmalloc(rlen + 1);
- if ((nr = pread(fd, line, rlen, off)) < 0) {
- cvs_log(LP_ERR, "preadline failed");
- xfree(line);
- return (NULL);
- }
+ if ((nr = pread(fd, line, rlen, off)) < 0)
+ fatal("preadline: %s", strerror(errno));
line[nr] = '\0';
return (line);
}
diff --git a/usr.bin/rcs/diff.c b/usr.bin/rcs/diff.c
index 7c5383ddbdc..4b806bb5d00 100644
--- a/usr.bin/rcs/diff.c
+++ b/usr.bin/rcs/diff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diff.c,v 1.28 2010/07/15 18:19:18 ray Exp $ */
+/* $OpenBSD: diff.c,v 1.29 2010/07/15 18:23:50 ray Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
* All rights reserved.
@@ -842,11 +842,8 @@ preadline(int fd, size_t rlen, off_t off)
ssize_t nr;
line = xmalloc(rlen + 1);
- if ((nr = pread(fd, line, rlen, off)) < 0) {
- warn("preadline failed");
- xfree(line);
- return (NULL);
- }
+ if ((nr = pread(fd, line, rlen, off)) < 0)
+ err(D_ERROR, "preadline");
line[nr] = '\0';
return (line);
}