From c021b9420f2d0d2465b564ebbda1f6b407aa7fe9 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 9 Sep 2020 11:56:19 -0600 Subject: [PATCH] state: ensure rc is set to 1 if strtoul() fails --- libifupdown/state.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libifupdown/state.c b/libifupdown/state.c index 344a417..6421aaa 100644 --- a/libifupdown/state.c +++ b/libifupdown/state.c @@ -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 });