Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0645dac

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 platformsit wouldn't be. In any case, this silences a compiler warning onOpenBSD (cf buildfarm member curculio).While at it, use snprintf not sprintf. This format string couldn'tpossibly overrun the supplied buffer, but that doesn't seem likea good reason not to use the safer style.Oversight in commitf828654. Back-patch to 9.6 where that came in.
1 parentc648f05 commit0645dac

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)

[8]ページ先頭

©2009-2025 Movatter.jp