summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
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/arch/amd64
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/arch/amd64')
-rw-r--r--sys/arch/amd64/stand/installboot/installboot.c4
1 files changed, 2 insertions, 2 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)