Use strtonum instead of atoi.

This commit is contained in:
nicm
2024-08-26 13:02:15 +00:00
parent 31b6c9356c
commit 2d1e93447e
3 changed files with 32 additions and 24 deletions

View File

@ -528,9 +528,10 @@ tty_term_create(struct tty *tty, char *name, char **caps, u_int ncaps,
struct options_array_item *a;
union options_value *ov;
u_int i, j;
const char *s, *value;
const char *s, *value, *errstr;
size_t offset, namelen;
char *first;
int n;
log_debug("adding term %s", name);
@ -564,8 +565,13 @@ tty_term_create(struct tty *tty, char *name, char **caps, u_int ncaps,
code->value.string = tty_term_strip(value);
break;
case TTYCODE_NUMBER:
code->type = TTYCODE_NUMBER;
code->value.number = atoi(value);
n = strtonum(value, 0, INT_MAX, &errstr);
if (errstr != NULL)
log_debug("%s: %s", ent->name, errstr);
else {
code->type = TTYCODE_NUMBER;
code->value.number = n;
}
break;
case TTYCODE_FLAG:
code->type = TTYCODE_FLAG;