Source-Changes-HG archive

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

[src/trunk]: src/sbin/gpt CID 1132762: Add error check for negative, to make ...



details:   https://anonhg.NetBSD.org/src/rev/3ab61e112553
branches:  trunk
changeset: 791668:3ab61e112553
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 27 20:40:48 2013 +0000

description:
CID 1132762: Add error check for negative, to make zero-divide in module
impossible.

diffstat:

 sbin/gpt/map.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diffs (23 lines):

diff -r 7c9cf6277b14 -r 3ab61e112553 sbin/gpt/map.c
--- a/sbin/gpt/map.c    Wed Nov 27 20:37:29 2013 +0000
+++ b/sbin/gpt/map.c    Wed Nov 27 20:40:48 2013 +0000
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: map.c,v 1.5 2013/11/20 08:08:47 jnemeth Exp $");
+__RCSID("$NetBSD: map.c,v 1.6 2013/11/27 20:40:48 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -194,6 +194,10 @@
 
        n = m->map_next;
 
+       if (size < 0 || alignment < 0) {
+               warnx("negative size or alignment");
+               return 0;
+       }
        if (size == 0 && alignment == 0) {
                if (n == NULL || n->map_type != MAP_TYPE_UNUSED)
                        return 0;



Home | Main Index | Thread Index | Old Index