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

Commitd398119

Browse files
committed
Improve our response to invalid format strings, and detect more cases.
Places that are testing for *printf failure ought to include the formatstring in their error reports, since bad-format-string is one of themore likely causes of such failure. This both makes it easier to findand repair the mistake, and provides at least some useful info to theuser who stumbles across such a problem.Also, tighten snprintf.c to report EINVAL for an invalid flag orfinal character in a format %-spec (including the case where the%-spec is missing a final character altogether). This seems likebetter project policy, and it also allows removing an instructionor two from the hot code path.Back-patch the error reporting change in pvsnprintf, since it should beharmless and may be helpful; but not the snprintf.c change.Per discussion of bug #15511 from Ertuğrul Kahveci, which reported aninvalid translated format string. These changes don't fix that error,but they should improve matters next time we make such a mistake.Discussion:https://postgr.es/m/15511-1d8b6a0bc874112f@postgresql.org
1 parent4173a61 commitd398119

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/common/psprintf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ pvsnprintf(char *buf, size_t len, const char *fmt, va_list args)
129129
if (nprinted<0&&errno!=0&&errno!=ENOMEM)
130130
{
131131
#ifndefFRONTEND
132-
elog(ERROR,"vsnprintf failed: %m");
132+
elog(ERROR,"vsnprintf failed: %m with format string \"%s\"",fmt);
133133
#else
134-
fprintf(stderr,"vsnprintf failed: %s\n",strerror(errno));
134+
fprintf(stderr,"vsnprintf failed: %m with format string \"%s\"\n",fmt);
135135
exit(EXIT_FAILURE);
136136
#endif
137137
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp