From 22ccb73099b145b7973948fd3b30af3b813f3ba8 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 3 May 2010 23:04:12 +0000 Subject: [PATCH] Prevent a -ve int -> uint32 underflow, noticed by joerg. If a partition ends up 0-sized, set it to FS_UNUSED to avoid later warnings. --- distrib/utils/sysinst/label.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/distrib/utils/sysinst/label.c b/distrib/utils/sysinst/label.c index 5c6529d34998..78c8d9751b2f 100644 --- a/distrib/utils/sysinst/label.c +++ b/distrib/utils/sysinst/label.c @@ -1,4 +1,4 @@ -/* $NetBSD: label.c,v 1.54 2010/01/02 21:16:46 dsl Exp $ */ +/* $NetBSD: label.c,v 1.55 2010/05/03 23:04:12 martin Exp $ */ /* * Copyright 1997 Jonathan Stone @@ -36,7 +36,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: label.c,v 1.54 2010/01/02 21:16:46 dsl Exp $"); +__RCSID("$NetBSD: label.c,v 1.55 2010/05/03 23:04:12 martin Exp $"); #endif #include @@ -195,6 +195,10 @@ edit_fs_size(menudesc *m, void *arg) if (size == ~0u) size = dlsize - p->pi_offset; p->pi_size = size; + if (size == 0) { + p->pi_offset = 0; + p->pi_fstype = FS_UNUSED; + } return 0; } @@ -880,6 +884,8 @@ getpartsize(uint32_t partstart, uint32_t defpartsize) NULL, isize, 1, (partend - partstart) / sizemult, multname); } + if (partend < partstart) + return 0; return (partend - partstart); } /* NOTREACHED */