]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[util] Treat empty integer strings as invalid
authorMichael Brown <mcb30@ipxe.org>
Fri, 19 Jun 2020 15:56:02 +0000 (16:56 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 19 Jun 2020 15:56:02 +0000 (16:56 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/util/efirom.c
src/util/elf2efi.c

index 93cd79fe9deb3fd1ec7e49c294e6e2dbca7253d6..8fa15ca901db3354c32021c8e63979d309d45e39 100644 (file)
@@ -207,14 +207,14 @@ static int parse_options ( const int argc, char **argv,
                switch ( c ) {
                case 'v':
                        opts->vendor = strtoul ( optarg, &end, 16 );
-                       if ( *end ) {
+                       if ( *end || ( ! *optarg ) ) {
                                eprintf ( "Invalid vendor \"%s\"\n", optarg );
                                exit ( 2 );
                        }
                        break;
                case 'd':
                        opts->device = strtoul ( optarg, &end, 16 );
-                       if ( *end ) {
+                       if ( *end || ( ! *optarg ) ) {
                                eprintf ( "Invalid device \"%s\"\n", optarg );
                                exit ( 2 );
                        }
index bcd53c9afda7880d42ec80c07f170edd4eae89c2..4f517d7d25e1af72cab02541134cd0542641160c 100644 (file)
@@ -996,7 +996,7 @@ static int parse_options ( const int argc, char **argv,
                switch ( c ) {
                case 's':
                        opts->subsystem = strtoul ( optarg, &end, 0 );
-                       if ( *end ) {
+                       if ( *end || ( ! *optarg ) ) {
                                eprintf ( "Invalid subsytem \"%s\"\n",
                                          optarg );
                                exit ( 2 );