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

Commit8f0d8f4

Browse files
committed
Fix one-byte buffer overrun in PQprintTuples().
This bug goes back to the original Postgres95 sources. Its significanceto modern PG versions is marginal, since we have not used PQprintTuples()internally in a very long time, and it doesn't seem to have ever beendocumented either. Still, it *is* exposed to client apps, so somebodyout there might possibly be using it.Xi Wang
1 parent535e69a commit8f0d8f4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

‎src/interfaces/libpq/fe-print.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,6 @@ PQprintTuples(const PGresult *res,
681681
inti,
682682
j;
683683
charformatString[80];
684-
685684
char*tborder=NULL;
686685

687686
nFields=PQnfields(res);
@@ -700,15 +699,15 @@ PQprintTuples(const PGresult *res,
700699
intwidth;
701700

702701
width=nFields*14;
703-
tborder=malloc(width+1);
702+
tborder=(char*)malloc(width+1);
704703
if (!tborder)
705704
{
706705
fprintf(stderr,libpq_gettext("out of memory\n"));
707706
abort();
708707
}
709-
for (i=0;i <=width;i++)
708+
for (i=0;i<width;i++)
710709
tborder[i]='-';
711-
tborder[i]='\0';
710+
tborder[width]='\0';
712711
fprintf(fout,"%s\n",tborder);
713712
}
714713

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp