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

Commit59d70a5

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 parent237dc2d commit59d70a5

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
@@ -686,7 +686,6 @@ PQprintTuples(const PGresult *res,
686686
inti,
687687
j;
688688
charformatString[80];
689-
690689
char*tborder=NULL;
691690

692691
nFields=PQnfields(res);
@@ -705,15 +704,15 @@ PQprintTuples(const PGresult *res,
705704
intwidth;
706705

707706
width=nFields*14;
708-
tborder=malloc(width+1);
707+
tborder=(char*)malloc(width+1);
709708
if (!tborder)
710709
{
711710
fprintf(stderr,libpq_gettext("out of memory\n"));
712711
exit(1);
713712
}
714-
for (i=0;i <=width;i++)
713+
for (i=0;i<width;i++)
715714
tborder[i]='-';
716-
tborder[i]='\0';
715+
tborder[width]='\0';
717716
fprintf(fout,"%s\n",tborder);
718717
}
719718

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp