]> The Tcpdump Group git mirrors - tcpdump/commit
Have a common routine for converting dates and times to strings.
authorGuy Harris <[email protected]>
Tue, 31 Jan 2023 07:03:16 +0000 (23:03 -0800)
committerDenis Ovsienko <[email protected]>
Fri, 7 Apr 2023 17:48:46 +0000 (18:48 +0100)
commit03c037bbd75588beba3ee09f26d17783d21e30bc
tree790610aff3b768053e58da1c693c83fb2c9b6f0a
parentea72743897e21aebc744b50eb535fc2d292bc81a
Have a common routine for converting dates and times to strings.

Have a routine that takes a buffer, a strftime format, and a struct tm *
as arguments, and:

* checks whether the struct tm * is null and, if so, returns a string
indicating that the date and time couldn't be converted;

* otherwise, passes it to strftime(), along with the buffer and the
format argument and, if strftime() returns 0, meaning the string didn't
fit into the buffer and thus that the buffer's contents are undefined,
returns a string indicating that the date and time didn't fit into the
buffer;

* otherwise, returns a pointer to the buffer.

Call that routine instead of directly calling strftime() in printers;
that prevents printing a buffer with undefined data if the buffer isn't
big enough for the string.

Also, when generating file names using an strftime format, check the
return value of strftime() to make sure the buffer didn't overflow.
netdissect.h
ntp.c
print-ahcp.c
print-arista.c
print-rx.c
print-zep.c
smbutil.c
tcpdump.c
util-print.c