dmidecode-devel
[Top][All Lists]
Advanced

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

[dmidecode] [PATCH v2 2/2] dmidecode: Argument processing


From: Jerry Hoemann
Subject: [dmidecode] [PATCH v2 2/2] dmidecode: Argument processing
Date: Fri, 29 Jun 2018 15:33:01 -0600

Tighten up the numberic argument processing for parse_opt_type and
parse_opt_oem_string to catch more typos.

Signed-off-by: Jerry Hoemann <address@hidden>
---
 dmiopt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dmiopt.c b/dmiopt.c
index 7a9963c..a142698 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.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]