state: ensure rc is set to 1 if strtoul() fails
This commit is contained in:
parent
910985cd22
commit
c021b9420f
1 changed files with 5 additions and 0 deletions
|
@ -32,8 +32,13 @@ lif_state_read(struct lif_dict *state, FILE *fd)
|
||||||
char *equals_p = strchr(linebuf, '=');
|
char *equals_p = strchr(linebuf, '=');
|
||||||
|
|
||||||
if (*refcount)
|
if (*refcount)
|
||||||
|
{
|
||||||
rc = strtoul(refcount, NULL, 10);
|
rc = strtoul(refcount, NULL, 10);
|
||||||
|
|
||||||
|
if (rc == 0 || rc == ULONG_MAX)
|
||||||
|
rc = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (equals_p == NULL)
|
if (equals_p == NULL)
|
||||||
{
|
{
|
||||||
lif_state_upsert(state, ifname, &(struct lif_interface){ .ifname = ifname, .refcount = rc });
|
lif_state_upsert(state, ifname, &(struct lif_interface){ .ifname = ifname, .refcount = rc });
|
||||||
|
|
Loading…
Reference in a new issue