# Bro segfaults with unknown linktype

**URL:** <https://community.zeek.org/t/bro-segfaults-with-unknown-linktype/1224>\
**Category:** Zeek\
**Created:** [September 18, 2007, 11:07am UTC](https://community.zeek.org/t/bro-segfaults-with-unknown-linktype/1224 "2007-09-18T11:07:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabian\_Schneider](https://avatars.discourse-cdn.com/v4/letter/f/90db22/32.png) [@Fabian\_Schneider](https://community.zeek.org/u/Fabian_Schneider)\
**Post date:** [September 18, 2007, 11:07am UTC](https://community.zeek.org/t/bro-segfaults-with-unknown-linktype/1224/1 "2007-09-18T11:07:44Z")

</div>

Hi,

we found a bug that segfaults bro. If you try to open a pcap file with a data link type that is unknown to libpcap (e.g. data link type 0x32), then it immediately crashes. The reason is in PktSrc.cc:

1.) In the constructor of PktFileSrc you first do an pcap\_open\_offline() and get a the pcap handle in pd.

2.) The you call SetHdrSize(), which calls Close() if no link type is found.

3.) Close closes pd, sets pd=0 and returns.

4.) back in PktFileSrc immediatly after SetHdrSize() you call pcap\_file(pd) with the nulled pd, which leads to the Segfault in pcap.

I have added the relevant code fragments and a backtrace of gdb:

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [September 19, 2007, 2:57am UTC](https://community.zeek.org/t/bro-segfaults-with-unknown-linktype/1224/2 "2007-09-19T02:57:31Z")

</div>

Thanks for tracking this down. I'll fix it.

Robin

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:38pm UTC](https://community.zeek.org/t/bro-segfaults-with-unknown-linktype/1224/3 "2022-05-06T15:38:21Z")

</div>

Closed on May 6, 2022, 3:38pm UTC


