appneta / tcpreplay

Pcap editing and replay tools for *NIX and Windows - Users please download source from
http://tcpreplay.appneta.com/wiki/installation.html#downloads
1.15k stars 268 forks source link

[Bug] Reachable assertion in tcpreplay, fast_edit_packet, src/send_packets.c:116 #772

Closed waugustus closed 1 year ago

waugustus commented 1 year ago

Describe the bug There is a reachable assertion error in fast_edit_packet, src/send_packets.c:116.

To Reproduce Steps to reproduce the behavior:

  1. build with

    CFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" CXXFLAGS="-g -fsanitize=address -fno-omit-frame-pointer" ./configure --prefix=$PWD/build_asan --disable-shared --enable-debug
  2. download the poc file

poc_116.zip

  1. run
    ./build_asan/bin/tcpreplay --unique-ip -l 4 --pps-multi 3 -p 200  -v -i eth0 poc

Expected behavior

$ gdb  -batch -ex "run" -ex "bt" --args ./build_asan/bin/tcpreplay --unique-ip -l 4 --pps-multi 3 -p 200  -v -i eth0 poc
warning: Error disabling address space randomization: Operation not permitted
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Detaching after fork from child process 126967]
reading from file -, link-type NULL (BSD loopback)
08:01:36.000096 [|null]
Warning in send_packets.c:send_packets() line 489:
Unable to send packet: Error with PF_PACKET send() [1]: Invalid argument (errno = 22)
11:32:08.1415590328 AF Unknown (8960), length 74: 
    0x0000:  0000 0000 0000 1114 08ff ff05 1045 d4c3  .............E..
    0x0010:  b2ff 0200 0400 0000 7012 0000 0000 603f  ........p.....`?
    0x0020:  00ff ffff 9910                           ......
11:29:35.1415590175 AF Unknown (4294961407), length 74: 
    0x0000:  f7e4 ff00 0000 8009 0800 4510 d4c3 b2a1  ..........E.....
    0x0010:  0200 0400 0017 1a29 0000 0040 603f 0000  .......)...@`?..
    0x0020:  0100 0010                                ....
11:29:04.1415590144 AF Unknown (255), length 65354: 
    0x0000:  f300 0000 ffff 7fff 0064 4045 d4c3 b2ff  .........d@E....
    0x0010:  0000 4a00 0000 0200 0400 005c 1a12 0000  ..J........\....
    0x0020:  0100 0000                                ....
[Detaching after fork from child process 127062]
tcpreplay: send_packets.c:116: fast_edit_packet: Assertion `l2len > 0' failed.
reading from file -, link-type NULL (BSD loopback)

Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50  ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff72e3859 in __GI_abort () at abort.c:79
#2  0x00007ffff72e3729 in __assert_fail_base (fmt=0x7ffff7479588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5555555d3f40 "l2len > 0", file=0x5555555d3f00 "send_packets.c", line=116, function=<optimized out>) at assert.c:92
#3  0x00007ffff72f4fd6 in __GI___assert_fail (assertion=0x5555555d3f40 "l2len > 0", file=0x5555555d3f00 "send_packets.c", line=116, function=0x5555555d5560 <__PRETTY_FUNCTION__.10166> "fast_edit_packet") at assert.c:101
#4  0x000055555556f1fa in fast_edit_packet (pkthdr=0x7fffffffdac0, pktdata=0x7fffffffd9e0, iteration=1, cached=false, datalink=0) at send_packets.c:116
#5  0x0000555555571b9c in send_packets (ctx=0x61e000000080, pcap=0x617000000400, idx=0) at send_packets.c:406
#6  0x0000555555583efc in replay_file (ctx=0x61e000000080, idx=0) at replay.c:182
#7  0x0000555555582e70 in tcpr_replay_index (ctx=0x61e000000080) at replay.c:59
#8  0x0000555555581be1 in tcpreplay_replay (ctx=0x61e000000080) at tcpreplay_api.c:1149
#9  0x000055555557a14d in main (argc=1, argv=0x7fffffffe600) at tcpreplay.c:180

System (please complete the following information):

tcpreplay version: 4.4.3 (build git:v4.4.2-1-g76644c24) (debug)

Additional context

fklassen commented 1 year ago

Fixed in PR #803