Skip to content

Commit 561ec76

Browse files
committed
psql: Fix invalid memory access
Due to an apparent thinko, when printing a table in expanded mode (\x), space would be allocated for 1 slot plus 1 byte per line, instead of 1 slot per line plus 1 slot for the NULL terminator. When the line count is small, reading or writing the terminator would therefore access memory beyond what was allocated.
1 parent f9325df commit 561ec76

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/bin/psql/print.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,8 +1210,8 @@ print_aligned_vertical(const printTableContent *cont, FILE *fout)
12101210
* We now have all the information we need to setup the formatting
12111211
* structures
12121212
*/
1213-
dlineptr = pg_local_malloc((sizeof(*dlineptr) + 1) * dheight);
1214-
hlineptr = pg_local_malloc((sizeof(*hlineptr) + 1) * hheight);
1213+
dlineptr = pg_local_malloc((sizeof(*dlineptr)) * (dheight + 1));
1214+
hlineptr = pg_local_malloc((sizeof(*hlineptr)) * (hheight + 1));
12151215

12161216
dlineptr->ptr = pg_local_malloc(dformatsize);
12171217
hlineptr->ptr = pg_local_malloc(hformatsize);

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