Content-Length: 265352 | pFad | http://github.com/postgrespro/postgres/commit/0645dacc371da6169b06934e3bd238c5f770fe25

75 Fix unsafe assumption that struct timeval.tv_sec is a "long". · postgrespro/postgres@0645dac · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/0645dacc371da6169b06934e3bd238c5f770fe25

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy