summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-01-24 12:09:55 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-01-24 12:09:55 +0000
commit573412fd7b9a8fe8e8a528839f7c9f91d9ca8f59 (patch)
tree89d9ddf891175ae7fdd3d88709cf4a2db8ddd237 /sys
parent6a25a789022c4f2c83d6f59608fa9679fdf9ddd5 (diff)
"read(..., ..., sizeof Y) < sizeof Y" is a dangerous idiom because it
does an unsigned comparison and read() can return -1. Use '!=' instead of '<' since read() can't return more than 'sizeof Y'. Not perfect (that would require a separate test for -1) but a very common usage. ok toby@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/stand/installboot/installboot.c4
-rw-r--r--sys/arch/i386/stand/installboot/installboot.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/sys/arch/amd64/stand/installboot/installboot.c b/sys/arch/amd64/stand/installboot/installboot.c
index a65de8e3e06..85bc9bf0399 100644
--- a/sys/arch/amd64/stand/installboot/installboot.c
+++ b/sys/arch/amd64/stand/installboot/installboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: installboot.c,v 1.7 2008/01/05 19:50:48 otto Exp $ */
+/* $OpenBSD: installboot.c,v 1.8 2008/01/24 12:09:53 krw Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@@ -201,7 +201,7 @@ main(int argc, char *argv[])
if (dl.d_type != 0 && dl.d_type != DTYPE_FLOPPY &&
dl.d_type != DTYPE_VND) {
if (lseek(devfd, (off_t)DOSBBSECTOR, SEEK_SET) < 0 ||
- read(devfd, &mbr, sizeof(mbr)) < sizeof(mbr))
+ read(devfd, &mbr, sizeof(mbr)) != sizeof(mbr))
err(4, "can't read master boot record");
if (mbr.dmbr_sign != DOSMBR_SIGNATURE)
diff --git a/sys/arch/i386/stand/installboot/installboot.c b/sys/arch/i386/stand/installboot/installboot.c
index 8070c087957..d8c7a7daa3a 100644
--- a/sys/arch/i386/stand/installboot/installboot.c
+++ b/sys/arch/i386/stand/installboot/installboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: installboot.c,v 1.50 2008/01/05 19:50:48 otto Exp $ */
+/* $OpenBSD: installboot.c,v 1.51 2008/01/24 12:09:54 krw Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@@ -197,7 +197,7 @@ main(int argc, char *argv[])
if (dl.d_type != 0 && dl.d_type != DTYPE_FLOPPY &&
dl.d_type != DTYPE_VND) {
if (lseek(devfd, (off_t)DOSBBSECTOR, SEEK_SET) < 0 ||
- read(devfd, &mbr, sizeof(mbr)) < sizeof(mbr))
+ read(devfd, &mbr, sizeof(mbr)) != sizeof(mbr))
err(4, "can't read master boot record");
if (mbr.dmbr_sign != DOSMBR_SIGNATURE)