Skip to content

Commit 3a5d0c5

Browse files
committed
Avoid reading below the start of a stack variable in tokenize_file().
We would wrongly overwrite the prior stack byte if it happened to contain '\n' or '\r'. New in 9.3, so no back-patch.
1 parent 813895e commit 3a5d0c5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/backend/libpq/hba.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ tokenize_file(const char *filename, FILE *file,
411411
line_number, filename)));
412412

413413
/* Strip trailing linebreak from rawline */
414-
while (rawline[strlen(rawline) - 1] == '\n' ||
415-
rawline[strlen(rawline) - 1] == '\r')
416-
rawline[strlen(rawline) - 1] = '\0';
414+
lineptr = rawline + strlen(rawline) - 1;
415+
while (lineptr >= rawline && (*lineptr == '\n' || *lineptr == '\r'))
416+
*lineptr-- = '\0';
417417

418418
lineptr = rawline;
419419
while (strlen(lineptr) > 0)

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