Module Name: src
Committed By: tsutsui
Date: Sun May 5 07:36:38 UTC 2024
Modified Files:
src/sys/arch/hp300/stand/mkboot: mkboot.c
Log Message:
Fix integer overflow of strtol(3) for "loadpoint" address on ILP32 hosts.
This strtol(3) was introduced in rev 1.12 for PR/57909 after netbsd-10,
but it returns LONG_MAX (0x7FFFFFFF) for 0xFFF00000 on ILP32 hosts and
the wrong loadpoint causes "NOT ENOUGH MEMORY" error by the BOOTROMs
on loading uboot.lif on (at least) my 9000/360 and 9000/425t.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hp300/stand/mkboot/mkboot.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/hp300/stand/mkboot/mkboot.c
diff -u src/sys/arch/hp300/stand/mkboot/mkboot.c:1.16 src/sys/arch/hp300/stand/mkboot/mkboot.c:1.17
--- src/sys/arch/hp300/stand/mkboot/mkboot.c:1.16 Fri May 3 15:39:50 2024
+++ src/sys/arch/hp300/stand/mkboot/mkboot.c Sun May 5 07:36:37 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mkboot.c,v 1.16 2024/05/03 15:39:50 christos Exp $ */
+/* $NetBSD: mkboot.c,v 1.17 2024/05/05 07:36:37 tsutsui Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -46,7 +46,7 @@ The Regents of the University of Califor
#ifdef notdef
static char sccsid[] = "@(#)mkboot.c 7.2 (Berkeley) 12/16/90";
#endif
-__RCSID("$NetBSD: mkboot.c,v 1.16 2024/05/03 15:39:50 christos Exp $");
+__RCSID("$NetBSD: mkboot.c,v 1.17 2024/05/05 07:36:37 tsutsui Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -78,7 +78,7 @@ __RCSID("$NetBSD: mkboot.c,v 1.16 2024/0
#define btolifs(b) (((b) + (SECTSIZE - 1)) / SECTSIZE)
#define lifstob(s) ((s) * SECTSIZE)
-int loadpoint = -1;
+uint32_t loadpoint = ULONG_MAX;
struct load ld;
struct lifvol lifv;
struct lifdir lifd[LIF_NUMDIR];
@@ -125,7 +125,7 @@ main(int argc, char **argv)
while ((ch = getopt(argc, argv, "l:t:")) != -1)
switch (ch) {
case 'l':
- loadpoint = strtol(optarg, NULL, 0);
+ loadpoint = strtoul(optarg, NULL, 0);
break;
case 't':
repro_epoch = (time_t)atoll(optarg);
@@ -136,7 +136,7 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (loadpoint == -1 || argc == 0)
+ if (loadpoint == ULONG_MAX || argc == 0)
usage();
n1 = argv[0];
argv++;