diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-24 12:09:55 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2008-01-24 12:09:55 +0000 |
commit | 573412fd7b9a8fe8e8a528839f7c9f91d9ca8f59 (patch) | |
tree | 89d9ddf891175ae7fdd3d88709cf4a2db8ddd237 /sys/arch/i386/stand/installboot | |
parent | 6a25a789022c4f2c83d6f59608fa9679fdf9ddd5 (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/i386/stand/installboot')
-rw-r--r-- | sys/arch/i386/stand/installboot/installboot.c | 4 |
1 files changed, 2 insertions, 2 deletions
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) |