From 5a83719602d847290f80e79c898f0a7543ce8778 Mon Sep 17 00:00:00 2001
From: Jerry Hoemann <jerry.hoemann@hpe.com>
Date: Tue, 3 Jul 2018 09:56:27 +0200
Subject: [PATCH 18/21] dmidecode: Argument processing
Tighten up the numeric argument processing for parse_opt_type and
parse_opt_oem_string to catch more typos.
Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmiopt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dmiopt.c b/dmiopt.c
index 1531ddf..2f285f3 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -113,7 +113,7 @@ static u8 *parse_opt_type(u8 *p, const char *arg)
char *next;
val = strtoul(arg, &next, 0);
- if (next == arg)
+ if (next == arg || (*next != '\0' && *next != ',' && *next != ' '))
{
fprintf(stderr, "Invalid type keyword: %s\n", arg);
print_opt_type_list();
@@ -228,7 +228,7 @@ static int parse_opt_oem_string(const char *arg)
goto done;
val = strtoul(arg, &next, 10);
- if (next == arg || val == 0x00 || val > 0xff)
+ if (next == arg || *next != '\0' || val == 0x00 || val > 0xff)
{
fprintf(stderr, "Invalid OEM string number: %s\n", arg);
return -1;
--
2.17.1