Skip to content

Different behavior with zero-padded interface numbers #1334

@momo-trip

Description

@momo-trip

Hi, is this tcpdump behavior a bug where interface index 9 fails with tcpdump -i 000000000000009 (14 zeros) but succeeds with tcpdump -i 0000000000000009 (15 zeros), despite both referring to the same interface?

Environment

  • OS: Ubuntu 22.04 LTS
  • Architecture: x86_64
  • tcpdump version:
$ ./tcpdump --version
tcpdump version 5.0.0-PRE-GIT
libpcap version 1.10.1 (with TPACKET_V3)
OpenSSL 3.0.2 15 Mar 2022
SMI-library: 0.4.8
64-bit build, 64-bit time_t

Issue

The same interface (index 9) produces different results based on zero-padding length. The threshold of 16 characters appears to be related to sizeof(ifr.ifr_name) (IFNAMSIZ).

Permission denied:

$ ./tcpdump -i 9                   # Permission denied
$ ./tcpdump -i 000000000000009     # Permission denied (15 characters total)

Works without sudo:

$ ./tcpdump -i 0000000000000009    # Works (16 characters total)
$ ./tcpdump -i dbus-session        # Works (interface name)

With sudo (different error):

$ sudo ./tcpdump -i 000000000000009
tcpdump: Failed to get session bus: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions