Jeremie Courreges-Anglas <j...@wxcvbn.org> writes:

> Lars Nooden <lars.noo...@gmail.com> writes:
>
>> On 12/13/16, Stuart Henderson wrote:
>>> On 2016/12/13 12:23, Lars Nooden wrote:
>>>> On a BeagleBone Black (one that has not been used for GPIO), I have
>>>> been getting segfaults with tcpdump since the last four or so
>>>> snapshots.  Running tcpdump in any way triggers the fault.
>>>
>>> A backtrace would be nice, or even better build with symbols and get
>>> a backtrace from that.
>>>
>>> if you don't have a full source checkout handy, you can just fetch tcpdump:
>>>   cd /usr; cvs get -P src/usr.sbin/tcpdump
>>>
>>> then:
>>>   cd /usr/src/usr.sbin/tcpdump
>>>   make obj; make clean; make DEBUG=-g
>>>   gdb obj/tcpdump
>>>   run
>>>   bt
>>>
>>> You can also do a date-based checkout ("cvs up -D 2016/11/23" etc) to
>>> narrow
>>> down the commit that broke it.
>>
>> Ok.  'make obj' failed without having the full source tree.  So now I have
>> everything and did:
>>
>> $ cd /usr/src/usr.sbin/tcpdump
>> $ make obj; make clean; make DEBUG=-g
>>
>> Then I ran gdb with the following results:
>>
>> # cd /usr/src/usr.sbin/tcpdump/
>> # gdb obj/tcpdump
>> GNU gdb 6.3
>> Copyright 2004 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and you are
>> welcome to change it and/or distribute copies of it under certain conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB.  Type "show warranty" for details.
>> This GDB was configured as "arm-unknown-openbsd6.0"...
>> (gdb) run
>> Starting program: /usr/obj/usr.sbin/tcpdump/tcpdump
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> *_libc_strlen (str=0x200 "\020@-\001")
>>     at /usr/src/lib/libc/string/strlen.c:39
>> 39              for (s = str; *s; ++s)
>> (gdb) bt
>> #0  *_libc_strlen (str=0x200 "\020@-\001")
>>     at /usr/src/lib/libc/string/strlen.c:39
>> #1  0x2fb1ffb8 in savestr (str=0x200 "\020@-\001")
>>     at /usr/src/usr.sbin/tcpdump/savestr.c:45
>> #2  0x2fae57e8 in init_addrtoname (localnet=Variable "localnet" is not
>> available.
>> )
>>     at /usr/src/usr.sbin/tcpdump/addrtoname.c:738
>> #3  0x2fae34c8 in main (argc=-1073903148, argv=Variable "argv" is not 
>> available.
>> )
>>     at /usr/src/usr.sbin/tcpdump/tcpdump.c:460
>>
>
> Thanks for the report.  I couldn't reproduce your issue at first since
> I kinda always use -n.  With the diff below I can't reproduce your
> issue even without -n.  The fallout is due to a change I made in
> libpcap; I had such a commit in mind for tcpdump but kinda forgot,
> since I didn't expect extern array vs. pointer to make a difference
> here.  *shrug*
>
> oks?

Technically all of this is memory that should not be modified.

I wonder whether I should add this in pcap-namedb.h, behind #ifdef
_BAD_TCPDUMP...


Index: addrtoname.c
===================================================================
RCS file: /d/cvs/src/usr.sbin/tcpdump/addrtoname.c,v
retrieving revision 1.36
diff -u -p -p -u -r1.36 addrtoname.c
--- addrtoname.c        18 Nov 2015 15:36:20 -0000      1.36
+++ addrtoname.c        13 Dec 2016 20:12:37 -0000
@@ -693,11 +693,11 @@ init_ipprotoarray(void)
                }
 }
 
-/*XXX from libbpfc.a */
-extern struct eproto {
+/* XXX from libpcap */
+extern const struct eproto {
        char *s;
        u_short p;
-} eproto_db[];
+} * const eproto_db;
 
 static void
 init_eprotoarray(void)


-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to