Skip to content

Commit

Permalink
fix printf format problem on machines with long tv_usec; version 2.6.7 (
Browse files Browse the repository at this point in the history
#228)

Co-authored-by: David Waitzman <djw@domaintools.com>
  • Loading branch information
djw1149 and David Waitzman authored May 19, 2024
1 parent 92f4b2b commit 52fd913
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern const struct verb verbs[];
#endif

EXTERN const char id_swclient[] INIT("dnsdbq");
EXTERN const char id_version[] INIT("2.6.6");
EXTERN const char id_version[] INIT("2.6.7");
EXTERN const char *program_name INIT(NULL);
EXTERN const char path_sort[] INIT("/usr/bin/sort");
EXTERN const char json_header[] INIT("Accept: application/json");
Expand Down
5 changes: 3 additions & 2 deletions time.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ timeval_str(const struct timeval *src, bool milliseconds) {
time_t t = (time_t)src->tv_sec;
struct tm result, *y = gmtime_r(&t, &result);
dst = ret + strftime(ret, sizeof ret, "%F %T", y);
long usecs = (long)src->tv_usec;
if (milliseconds)
sprintf(dst, ".%03d", src->tv_usec % 1000);
sprintf(dst, ".%03ld", usecs % 1000);
else
sprintf(dst, ".%06d", src->tv_usec % 1000000);
sprintf(dst, ".%06ld", usecs % 1000000);
return ret;
}

Expand Down

0 comments on commit 52fd913

Please sign in to comment.