diff options
author | 2011-06-20 19:10:41 +0000 | |
---|---|---|
committer | 2011-06-20 19:10:41 +0000 | |
commit | acf6f482ff2f13bc68243575673c57e1eb46393f (patch) | |
tree | ef73b700d4359aac9dadadc58d8d61a8ac5f14a0 | |
parent | fix a segfault found by jasper@ (diff) | |
download | wireguard-openbsd-acf6f482ff2f13bc68243575673c57e1eb46393f.tar.xz wireguard-openbsd-acf6f482ff2f13bc68243575673c57e1eb46393f.zip |
MBR_read() can be reading from a file as well as a raw partition.
And files can be smaller (e.g. 512 bytes like /usr/mdec/mbr) than
a disk sector (e.g. 4096 bytes on pirofti's external disk drive).
So relax the length test on the read() result to < DEV_BSIZE (the
amount of data we actually want) instead of < secsize (the minimum
size that read() will accept).
'fdisk -e' and 'fdisk -i' now work on devices with sector sizes
greater than DEV_BSIZE.
-rw-r--r-- | sbin/fdisk/mbr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index b8cbec17126..b8f05bdded4 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.26 2011/02/21 19:26:13 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.27 2011/06/20 19:10:41 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -169,7 +169,7 @@ MBR_read(int fd, off_t where, char *buf) if (len == -1) return (-1); - if (len != secsize) { + if (len < DEV_BSIZE) { /* short read */ errno = EIO; return (-1); |