summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-10-20 15:10:41 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-10-20 15:10:41 +0200
commit9addb47bec772b53a66c39efdd404290300d0e86 (patch)
tree71f86f9157a8b265f1e0db483aabda571fca2465
parentabafb7e1679f268fea1f5b0f911cb75fcda44857 (diff)
trafgen: fix NULL pointer dereference in -i option parsing
If trafgen is called with the -i option, it currently crashes due to an NULL pointer dereference. Fix it. Fixes Coverity CID 1381809 Fixes: 82a3c204c6f1 ("trafgen: Allow send packets from pcap file") Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--trafgen.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/trafgen.c b/trafgen.c
index 9c5a9a6..d2d43bb 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -1097,15 +1097,13 @@ int main(int argc, char **argv)
case 'J':
ctx.jumbo_support = true;
break;
+ case 'c':
case 'i':
confname = xstrdup(optarg);
- if (strstr(confname, ".pcap")) {
+ if (c == 'i' && strstr(confname, ".pcap")) {
ctx.sh.type = SHAPER_TSTAMP;
ctx.pcap_in = confname;
- break;
- }
- case 'c':
- if (!strncmp("-", confname, strlen("-")))
+ } else if (!strncmp("-", confname, strlen("-")))
ctx.cpus = 1;
break;
case 'u':