Content-Length: 270016 | pFad | http://github.com/postgrespro/postgres/commit/3a5d0c55338e6beb4c01ed5fadb1462e90db7545

04 Avoid reading below the start of a stack variable in tokenize_file(). · postgrespro/postgres@3a5d0c5 · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/3a5d0c55338e6beb4c01ed5fadb1462e90db7545

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy