Skip to content

Commit 0645dac

Browse files
committed
Fix unsafe assumption that struct timeval.tv_sec is a "long".
It typically is a "long", but it seems possible that on some platforms it wouldn't be. In any case, this silences a compiler warning on OpenBSD (cf buildfarm member curculio). While at it, use snprintf not sprintf. This format string couldn't possibly overrun the supplied buffer, but that doesn't seem like a good reason not to use the safer style. Oversight in commit f828654. Back-patch to 9.6 where that came in.
1 parent c648f05 commit 0645dac

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/utils/error/elog.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,8 +2484,9 @@ log_line_prefix(StringInfo buf, ErrorData *edata)
24842484
saved_timeval_set = true;
24852485
}
24862486

2487-
sprintf(strfbuf, "%ld.%03d", saved_timeval.tv_sec,
2488-
(int) (saved_timeval.tv_usec / 1000));
2487+
snprintf(strfbuf, sizeof(strfbuf), "%ld.%03d",
2488+
(long) saved_timeval.tv_sec,
2489+
(int) (saved_timeval.tv_usec / 1000));
24892490

24902491
if (padding != 0)
24912492
appendStringInfo(buf, "%*s", padding, strfbuf);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy