- /* TODO Replace atoi with strtol and check for errors */
- chan.attr.switch_timer_interval = atoi(poptGetOptArg(pc));
+ {
+ unsigned long v;
+
+ errno = 0;
+ v = strtoul(poptGetOptArg(pc), NULL, 0);
+ if (errno != 0) {
+ ERR("Wrong value the --switch-timer parameter: %s", opt_arg);
+ ret = CMD_ERROR;
+ goto end;
+ }
+ if (v != (uint32_t) v) {
+ ERR("32-bit overflow in --switch-timer parameter: %s", opt_arg);
+ ret = CMD_ERROR;
+ goto end;
+ }
+ chan.attr.switch_timer_interval = (uint32_t) v;