state: ensure rc is set to 1 if strtoul() fails

This commit is contained in:
Ariadne Conill 2020-09-09 11:56:19 -06:00
parent 910985cd22
commit c021b9420f

View file

@ -32,8 +32,13 @@ lif_state_read(struct lif_dict *state, FILE *fd)
char *equals_p = strchr(linebuf, '=');
if (*refcount)
{
rc = strtoul(refcount, NULL, 10);
if (rc == 0 || rc == ULONG_MAX)
rc = 1;
}
if (equals_p == NULL)
{
lif_state_upsert(state, ifname, &(struct lif_interface){ .ifname = ifname, .refcount = rc });