Skip to content

Commit 8f0d8f4

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 535e69a commit 8f0d8f4

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
int i,
682682
j;
683683
char formatString[80];
684-
685684
char *tborder = NULL;
686685

687686
nFields = PQnfields(res);
@@ -700,15 +699,15 @@ PQprintTuples(const PGresult *res,
700699
int width;
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)
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