Changeset 964e897 in mainline for uspace/app/hrctl/hrctl.c


Ignore:
Timestamp:
2025-05-07T12:12:18Z (5 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
fde80323
Parents:
56602e0
Message:

hrctl: handle invalid level argument

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/hrctl/hrctl.c

    r56602e0 r964e897  
    3434 */
    3535
     36#include <ctype.h>
    3637#include <errno.h>
    3738#include <getopt.h>
     
    275276                }
    276277
    277                 vol_config->level = strtol(argv[optind++], NULL, 10);
     278                const char *level_str = argv[optind++];
     279                if (str_size(level_str) != 1 && !isdigit(level_str[0])) {
     280                        printf(NAME ": unknown level \"%s\"\n", level_str);
     281                        goto error;
     282                }
     283
     284                vol_config->level = strtol(level_str, NULL, 10);
    278285
    279286                errno_t rc = fill_config_devs(argc, argv, vol_config);
Note: See TracChangeset for help on using the changeset viewer.