Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/mkubootimage Let address/entry be 64bit if they are ...



details:   https://anonhg.NetBSD.org/src/rev/ff55868c1042
branches:  trunk
changeset: 777388:ff55868c1042
user:      matt <matt%NetBSD.org@localhost>
date:      Fri Feb 17 08:11:28 2012 +0000

description:
Let address/entry be 64bit if they are just sign-extended 32-bit values.
(change pulled up from matt-nb5-mips64).

diffstat:

 usr.bin/mkubootimage/mkubootimage.c |  16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diffs (52 lines):

diff -r 276d070e7e39 -r ff55868c1042 usr.bin/mkubootimage/mkubootimage.c
--- a/usr.bin/mkubootimage/mkubootimage.c       Fri Feb 17 07:51:51 2012 +0000
+++ b/usr.bin/mkubootimage/mkubootimage.c       Fri Feb 17 08:11:28 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mkubootimage.c,v 1.14 2011/09/04 20:35:07 joerg Exp $ */
+/* $NetBSD: mkubootimage.c,v 1.15 2012/02/17 08:11:28 matt Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkubootimage.c,v 1.14 2011/09/04 20:35:07 joerg Exp $");
+__RCSID("$NetBSD: mkubootimage.c,v 1.15 2012/02/17 08:11:28 matt Exp $");
 
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -322,7 +322,7 @@
        char *ep;
        int kernel_fd, image_fd;
        int ch;
-       unsigned long num;
+       unsigned long long num;
 
        while ((ch = getopt(argc, argv, "A:C:E:O:T:a:e:hm:n:")) != -1) {
                switch (ch) {
@@ -340,18 +340,20 @@
                        break;
                case 'a':       /* addr */
                        errno = 0;
-                       num = strtoul(optarg, &ep, 0);
+                       num = strtoull(optarg, &ep, 0);
                        if (*ep != '\0' || (errno == ERANGE &&
-                           (num == ULONG_MAX || num == 0)))
+                           (num == ULLONG_MAX || num == 0)) ||
+                           (num != (int32_t)num && num != (uint32_t)num))
                                errx(1, "illegal number -- %s", optarg);
                        image_loadaddr = (uint32_t)num;
                        break;
                case 'E':       /* ep (byte swapped) */
                case 'e':       /* ep */
                        errno = 0;
-                       num = strtoul(optarg, &ep, 0);
+                       num = strtoull(optarg, &ep, 0);
                        if (*ep != '\0' || (errno == ERANGE &&
-                           (num == ULONG_MAX || num == 0)))
+                           (num == ULLONG_MAX || num == 0)) ||
+                           (num != (int32_t)num && num != (uint32_t)num))
                                errx(1, "illegal number -- %s", optarg);
                        image_entrypoint = (uint32_t)num;
                        if (ch == 'E')



Home | Main Index | Thread Index | Old Index