From fee99ccfd2fb3605c4392e8d8fb22fedb39c743c Mon Sep 17 00:00:00 2001 From: Dave Anderson Date: Fri, 28 Jun 2019 14:03:35 -0400 Subject: [PATCH] Fix to the x86_64 "--machdep phys_base=" command line option to allow the use of a negative decimal number as the value. Without the patch, only the hexadecimal representation of the value would be accepted. (v-santy@microsoft.com, anderson@redhat.com) --- x86_64.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/x86_64.c b/x86_64.c index 3d31445..d57b602 100644 --- a/x86_64.c +++ b/x86_64.c @@ -5999,13 +5999,12 @@ parse_cmdline_args(void) } p = arglist[i] + strlen("phys_base="); if (strlen(p)) { - if (megabytes) { - value = dtol(p, RETURN_ON_ERROR|QUIET, - &errflag); - } else - value = htol(p, RETURN_ON_ERROR|QUIET, - &errflag); - if (!errflag) { + if (hexadecimal(p, 0) && !decimal(p, 0) && + !STRNEQ(p, "0x") && !STRNEQ(p, "0X")) + string_insert("0x", p); + errno = 0; + value = strtoull(p, NULL, 0); + if (!errno) { if (megabytes) value = MEGABYTES(value); machdep->machspec->phys_base = value;