Skip to content

Commit 59d70a5

Browse files
committed
Fix one-byte buffer overrun in PQprintTuples().
This bug goes back to the original Postgres95 sources. Its significance to 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 been documented either. Still, it *is* exposed to client apps, so somebody out there might possibly be using it. Xi Wang
1 parent 237dc2d commit 59d70a5

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
int i,
687687
j;
688688
char formatString[80];
689-
690689
char *tborder = NULL;
691690

692691
nFields = PQnfields(res);
@@ -705,15 +704,15 @@ PQprintTuples(const PGresult *res,
705704
int width;
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy