From bf4e7c9c0d77bbf45b654082db552b196f8fd7a1 Mon Sep 17 00:00:00 2001 From: "David M. Syzdek" Date: Mon, 11 Oct 2021 18:59:53 -0800 Subject: numconvert: requiring prefix for Hex input --- src/numconvert.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/numconvert.c b/src/numconvert.c index b852194..e7b3a8c 100644 --- a/src/numconvert.c +++ b/src/numconvert.c @@ -288,13 +288,10 @@ int main(int argc, char * argv[]) optbase = 8; else { - for(y = 0; ( ((uint32_t)y) < strlen(argv[x]) && (optbase != -1) ); y++) - { - if ( (optbase < 10) && ((argv[x][y] >= '0') && (argv[x][y] <= '9')) ) optbase = 10; - else if ( (optbase < 16) && ((argv[x][y] >= 'a') && (argv[x][y] <= 'f')) ) optbase = 16; - else if ( (optbase < 16) && ((argv[x][y] >= 'a') && (argv[x][y] <= 'F')) ) optbase = 16; - else optbase = -1; - }; + optbase = 10; + for(y = 0; ( ((uint32_t)y) < strlen(argv[x]) && (optbase == 10) ); y++) + if ((argv[x][y] < '0') || (argv[x][y] > '9')) + optbase = -1; }; }; -- cgit v1.2.3