[tcpdump-workers] snprintf in libpcap

Guy Harris gharris at sonic.net
Mon Mar 2 16:51:55 EST 2020


On Mar 2, 2020, at 1:22 PM, Michael Richardson via tcpdump-workers <tcpdump-workers at lists.tcpdump.org> wrote:

> Back in 2016, we note in the CHANGES:
>   Replace sprintf() with pcap_snprintf().
> 
> but, we have no prototype for this, and apparently no definition, and we use
> snprintf() everywhere.  I'm trying to merge Ray's changes which are rebased
> into pull request #914.
> 
> I think that we just use "snprintf()" now.

In the master branch, we require versions of Visual Studio that support a C99-compatible snprintf(), and we also require C99-compatible snprintf() support on UN*Xes.

Earlier versions 1) had pcap_snprintf() and 2) either declared it and provided it, or just #defined pcap_snprintf to be snprintf.

Note that #914 also uses structure initializations that initialize fields by name, which is also a C99-ism and which I think sufficiently recent versions of Visual Studio support; I'm OK with requiring support for that (1990 called, it wants its C standard back...).


More information about the tcpdump-workers mailing list