| 1 | Avoid usage of PATH_MAX.
|
| 2 |
|
| 3 | Submitted to [email protected].
|
| 4 |
|
| 5 | From ef652341ed8b2c14ac40312ccd4ed329cb69fd0c Mon Sep 17 00:00:00 2001
|
| 6 | From: Jan Nieuwenhuizen <[email protected]>
|
| 7 | Date: Sat, 7 Mar 2020 14:57:19 +0100
|
| 8 | Subject: [PATCH] Avoid usage of PATH_MAX.
|
| 9 |
|
| 10 | * filename.c (lrealpath): Have realpath allocate the buffer. Fixes
|
| 11 | compilation on the Hurd and avoids possible buffer overflow on other
|
| 12 | systems.
|
| 13 | ---
|
| 14 | filename.c | 6 +++---
|
| 15 | 1 file changed, 3 insertions(+), 3 deletions(-)
|
| 16 |
|
| 17 | diff --git a/filename.c b/filename.c
|
| 18 | index e420837..faa71b0 100644
|
| 19 | |
| 20 | |
| 21 | @@ -795,9 +795,9 @@ lrealpath(path)
|
| 22 | char *path;
|
| 23 | {
|
| 24 | #if HAVE_REALPATH
|
| 25 | - char rpath[PATH_MAX];
|
| 26 | - if (realpath(path, rpath) != NULL)
|
| 27 | - return (save(rpath));
|
| 28 | + char *rpath = NULL;
|
| 29 | + if ((rpath = realpath(path, rpath)) != NULL)
|
| 30 | + return (rpath);
|
| 31 | #endif
|
| 32 | return (save(path));
|
| 33 | }
|
| 34 | --
|
| 35 | 2.24.0
|
| 36 |
|