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

Commite7db8fa

Browse files
committed
Add Assert check to catch vsnprintf overrunning its buffer. (Seen to
occur on Solaris 7 in 64-bit mode, for one.)
1 parentaa39e9a commite7db8fa

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

‎src/backend/lib/stringinfo.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: stringinfo.c,v 1.29 2001/10/25 05:49:29 momjian Exp $
12+
* $Id: stringinfo.c,v 1.30 2002/03/04 18:34:02 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -114,11 +114,22 @@ appendStringInfo(StringInfo str, const char *fmt,...)
114114
avail=str->maxlen-str->len-1;
115115
if (avail>16)
116116
{
117+
/*
118+
* Assert check here is to catch buggy vsnprintf that overruns
119+
* the specified buffer length. Solaris 7 in 64-bit mode is
120+
* an example of a platform with such a bug.
121+
*/
122+
#ifdefUSE_ASSERT_CHECKING
123+
str->data[str->maxlen-1]='\0';
124+
#endif
125+
117126
va_start(args,fmt);
118127
nprinted=vsnprintf(str->data+str->len,avail,
119128
fmt,args);
120129
va_end(args);
121130

131+
Assert(str->data[str->maxlen-1]=='\0');
132+
122133
/*
123134
* Note: some versions of vsnprintf return the number of chars
124135
* actually stored, but at least one returns -1 on failure. Be

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp