summaryrefslogtreecommitdiff
path: root/sbin/pdisk/partition_map.c
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2016-01-23 14:10:06 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2016-01-23 14:10:06 +0000
commit03ba620b15fd471b7b42d2131183891c27fad85f (patch)
tree242ef01e1a2c516801a842477956daf129e72f89 /sbin/pdisk/partition_map.c
parenta34935185bb9ca472f267b8f147c34e360f0545d (diff)
Add comments to ensure future spelunkers realize that struct block0
and struct dpme must be 512-bytes long at the moment. Use this fact to avoid using DEV_BSIZE and thus replace #include <param.h> with #include <types.h> in pdisk.c. Constrain media size to UINT32_MAX, the actual limit, instead of LONG_MAX, which could be way more on some theoretical future arch running pdisk. And do the constraint inside open_partition_map().
Diffstat (limited to 'sbin/pdisk/partition_map.c')
-rw-r--r--sbin/pdisk/partition_map.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index f80f8a8ef9f..2779db42665 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: partition_map.c,v 1.56 2016/01/23 13:24:15 krw Exp $ */
+/* $OpenBSD: partition_map.c,v 1.57 2016/01/23 14:10:05 krw Exp $ */
/*
* partition_map.c - partition map routines
@@ -28,6 +28,7 @@
*/
#include <sys/param.h> /* DEV_BSIZE */
+#include <sys/stdint.h>
#include <err.h>
#include <stdio.h>
@@ -93,7 +94,11 @@ open_partition_map(int fd, char *name, uint64_t mediasz)
map->logical_block = DEV_BSIZE;
map->blocks_in_map = 0;
map->maximum_in_map = -1;
- map->media_size = mediasz;
+
+ if (mediasz > UINT32_MAX)
+ map->media_size = UINT32_MAX;
+ else
+ map->media_size = mediasz;
map->block0 = malloc(DEV_BSIZE);
if (map->block0 == NULL) {