Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst Prevent a -ve int -> uint32 underflow, ...



details:   https://anonhg.NetBSD.org/src/rev/b8accf38518a
branches:  trunk
changeset: 754553:b8accf38518a
user:      martin <martin%NetBSD.org@localhost>
date:      Mon May 03 23:04:12 2010 +0000

description:
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.

diffstat:

 distrib/utils/sysinst/label.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 4dba94c2bfbc -r b8accf38518a distrib/utils/sysinst/label.c
--- a/distrib/utils/sysinst/label.c     Mon May 03 22:12:32 2010 +0000
+++ b/distrib/utils/sysinst/label.c     Mon May 03 23:04:12 2010 +0000
@@ -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 <sys/cdefs.h>
 #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 <sys/types.h>
@@ -195,6 +195,10 @@
        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 @@
                            NULL, isize, 1,
                            (partend - partstart) / sizemult, multname);
                }
+               if (partend < partstart)
+                       return 0;
                return (partend - partstart);
        }
        /* NOTREACHED */



Home | Main Index | Thread Index | Old Index