commit f37d097c1c8468572d2d39a0cdea5f5a9ecc757e
parent 191cf671be155fb425b31855cc0044636f75470a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 4 Mar 2024 11:18:05 +0100
rcfile: avoid crashing on an include path that is way too long
The `gnulib` globbing module apparently does not handle an overload
of slashes well, so avoid feeding it more than it can take.
This fixes https://savannah.gnu.org/bugs/?65407.
Problem probably existed since version 2.3.3,
since globbing was introduced.
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -974,6 +974,11 @@ void parse_includes(char *ptr)
pattern++;
ptr = parse_argument(ptr);
+ if (strlen(pattern) > PATH_MAX) {
+ jot_error(N_("Path is too long"));
+ return;
+ }
+
/* Expand a tilde first, then try to match the globbing pattern. */
expanded = real_dir_from_tilde(pattern);
result = glob(expanded, GLOB_ERR|GLOB_NOCHECK, NULL, &files);