summaryrefslogtreecommitdiffstats
path: root/lib/cli
diff options
context:
space:
mode:
authorNicolas PLANEL <nicolas.planel@enovance.com>2014-08-26 15:21:12 (GMT)
committerThomas Haller <thaller@redhat.com>2014-08-27 10:56:34 (GMT)
commita640e97a2265ef241da0873593308907d71f1b3f (patch)
tree81b3bdaebc96fa3f83d9ad9b6dd2b525cfd1be5e /lib/cli
parent54ae1d95a43ac73aaae007990c102358cec43d30 (diff)
downloadlibnl-a640e97a2265ef241da0873593308907d71f1b3f.zip
libnl-a640e97a2265ef241da0873593308907d71f1b3f.tar.gz
libnl-a640e97a2265ef241da0873593308907d71f1b3f.tar.bz2
qdisc: avoid calling strstr() with a NULL haystack
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/cli')
-rw-r--r--lib/cli/qdisc/hfsc.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/cli/qdisc/hfsc.c b/lib/cli/qdisc/hfsc.c
index 1e6878a..6a0c960 100644
--- a/lib/cli/qdisc/hfsc.c
+++ b/lib/cli/qdisc/hfsc.c
@@ -81,12 +81,13 @@ hfsc_get_sc(char *optarg, struct tc_service_curve *sc)
{
unsigned int m1 = 0, d = 0, m2 = 0;
char *tmp = strdup(optarg);
- char *p = tmp, *endptr;
+ char *p, *endptr;
+ char *pp = tmp;
if (!tmp)
return -ENOMEM;
- p = strstr(p, "m1:");
+ p = strstr(pp, "m1:");
if (p) {
char *q;
p += 3;
@@ -99,10 +100,10 @@ hfsc_get_sc(char *optarg, struct tc_service_curve *sc)
m1 = strtoul(p, &endptr, 10);
if (endptr == p)
goto err;
- p = q + 1;
- }
+ pp = q + 1;
+ }
- p = strstr(p, "d:");
+ p = strstr(pp, "d:");
if (p) {
char *q;
p += 2;
@@ -115,10 +116,10 @@ hfsc_get_sc(char *optarg, struct tc_service_curve *sc)
d = strtoul(p, &endptr, 10);
if (endptr == p)
goto err;
- p = q + 1;
- }
+ pp = q + 1;
+ }
- p = strstr(p, "m2:");
+ p = strstr(pp, "m2:");
if (p) {
p += 3;
if (*p == 0)
@@ -126,7 +127,7 @@ hfsc_get_sc(char *optarg, struct tc_service_curve *sc)
m2 = strtoul(p, &endptr, 10);
if (endptr == p)
goto err;
- } else
+ } else
goto err;
free(tmp);