shell: prevent overflow of IDs

master
S.J.R. van Schaik 6 years ago
parent e05afe9cc9
commit efb5a23859
  1. 2
      source/shell/buzzer.c
  2. 2
      source/shell/led.c

@ -26,7 +26,7 @@ int shell_buzzer(struct console *con, size_t argc, const char **argv)
fprintf(con->fp, "%u %d %u\n", buzzer_id, state, freq);
if (buzzer_id > nbuzzers) {
if (buzzer_id >= nbuzzers) {
fprintf(con->fp, "error: invalid buzzer ID %d\n", buzzer_id);
return -1;
}

@ -21,7 +21,7 @@ int shell_led(struct console *con, size_t argc, const char **argv)
if (argc >= 1)
led_id = strtoul(argv[0], NULL, 0);
if (led_id > nleds) {
if (led_id >= nleds) {
fprintf(con->fp, "error: unknown LED ID %d\n", led_id);
return -1;
}

Loading…
Cancel
Save