diff options
| author | Archie Cobbs <archie@FreeBSD.org> | 1999-11-02 23:18:01 +0000 |
|---|---|---|
| committer | Archie Cobbs <archie@FreeBSD.org> | 1999-11-02 23:18:01 +0000 |
| commit | 2b70adcbbe52d78f5828fe5c14850f6817c83d4a (patch) | |
| tree | 933dc4cbd306643fb4cfaef4087fa80525fd8420 /sys/netgraph/ng_sample.c | |
| parent | 44b4dd855d482ba49d18c811ffb9bc05e89b961c (diff) | |
Notes
Diffstat (limited to 'sys/netgraph/ng_sample.c')
| -rw-r--r-- | sys/netgraph/ng_sample.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/netgraph/ng_sample.c b/sys/netgraph/ng_sample.c index 6cc365c66e8c..8e2da751637e 100644 --- a/sys/netgraph/ng_sample.c +++ b/sys/netgraph/ng_sample.c @@ -176,17 +176,17 @@ ng_xxx_newhook(node_p node, hook_p hook, const char *name) * hooks start with 'dlci' and have a decimal trailing channel * number up to 4 digits Use the leadin defined int he associated .h * file. */ - if (strncmp(name, NG_XXX_HOOK_DLCI_LEADIN, 4) == 0) { + if (strncmp(name, + NG_XXX_HOOK_DLCI_LEADIN, strlen(NG_XXX_HOOK_DLCI_LEADIN)) == 0) { + const char *eptr; + cp = name + sizeof(NG_XXX_HOOK_DLCI_LEADIN); - while ((digits < 5) - && ((c = *cp++) > '0') && (c < '9')) { - dlci *= 10; - dlci += c - '0'; - digits++; - } - if ((c != 0) || (digits == 5) - || (dlci <= 0) || (dlci > 1023)) + if (!isdigit(*cp) || (cp[0] == '0' && cp[1] != '\0')) return (EINVAL); + dlci = (int)strtoul(cp, &eptr, 10); + if (*eptr != '\0' || dlci < 0 || dlci > 1023) + return (EINVAL); + /* We have a dlci, now either find it, or allocate it */ for (chan = 0; chan < XXX_NUM_DLCIS; chan++) if (xxxp->channel[chan].dlci == dlci) |
