Commit Graph

3 Commits

Author SHA1 Message Date
Guy Harris
7578e1c04e 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.
2023-02-02 15:43:24 +01:00
Guy Harris
af51eea290 configure, CMakeLists.txt: don't check for snprintf().
It's specified by the C90 standard (and, as I remember, by the C89
standard, although I no longer have my paper copy); no need to worry
about ancient environments that lack it, and we have some cases where we
call it in code not protected by #ifdef HAVE_STRFTIME/#endif and haven't
seen any reports of problems.
2023-01-30 12:46:44 -08:00
Herwin Weststrate
763bef5f53 Extract NTP printing
This method is required to dissect some RADIUS attributes
2020-04-21 23:50:03 +02:00