[Git][debian-proftpd-team/proftpd][master] Add patch for (Issue #2473).
Hilmar Preuße (@hilmar)
gitlab at salsa.debian.org
Wed Nov 18 21:36:10 GMT 2026
Hilmar Preuße pushed to branch master at Debian ProFTPD Team / proftpd
Commits:
220ccd4a by Hilmar Preuße at 2026-11-18T22:35:59+01:00
Add patch for (Issue #2473).
- - - - -
3 changed files:
- debian/changelog
- + debian/patches/549f81741f930acab56dfb4620c7603de05c20f2.diff
- debian/patches/series
Changes:
=====================================
debian/changelog
=====================================
@@ -1,6 +1,7 @@
proftpd-dfsg (1.3.9e~dfsg-4) UNRELEASED; urgency=medium
* Add patch for (Issue #2360).
+ * Add patch for (Issue #2473).
-- Hilmar Preuße <hille42 at debian.org> Thu, 12 Nov 2026 23:54:51 +0100
=====================================
debian/patches/549f81741f930acab56dfb4620c7603de05c20f2.diff
=====================================
@@ -0,0 +1,238 @@
+From 549f81741f930acab56dfb4620c7603de05c20f2 Mon Sep 17 00:00:00 2001
+From: TJ Saunders <tj at castaglia.org>
+Date: Wed, 18 Nov 2026 13:28:36 -0800
+Subject: [PATCH] Issue #2473: Backport a fix from glibc `glob(3)` for handling
+ unbalanced brace expansions.
+
+---
+ lib/glibc-glob.c | 97 ++++++++++++++++++++++++------------------------
+ tests/api/fsio.c | 17 +++++++--
+ 2 files changed, 62 insertions(+), 52 deletions(-)
+
+--- proftpd.orig/lib/glibc-glob.c
++++ proftpd/lib/glibc-glob.c
+@@ -354,12 +354,8 @@
+ #else
+ extern char *getlogin __P ((void));
+ #endif
+-
+-static
+-#if __GNUC__ - 0 >= 2
+-inline
+-#endif
+-const char *next_brace_sub __P ((const char *begin));
++
++static const char *next_brace_sub __P ((const char *begin, int flags));
+
+ #endif /* GLOB_ONLY_P */
+
+@@ -380,48 +376,29 @@
+ static int prefix_array __P ((const char *prefix, char **array, size_t n));
+ static int collated_compare __P ((const __ptr_t, const __ptr_t));
+
+-/* Find the end of the sub-pattern in a brace expression. We define
+- this as an inline function if the compiler permits. */
+-static
+-#if __GNUC__ - 0 >= 2
+-inline
+-#endif
+-const char *
+-next_brace_sub (const char *begin)
++/* Find the end of the sub-pattern in a brace expression. */
++static const char *
++next_brace_sub (const char *cp, int flags)
+ {
+ unsigned int depth = 0;
+- const char *cp = begin;
+-
+- while (1)
+- {
+- if (depth == 0)
+- {
+- if (*cp != ',' && *cp != '}' && *cp != '\0')
+- {
+- if (*cp == '{')
+- ++depth;
+- ++cp;
+- continue;
+- }
+- }
+- else
+- {
+- while (*cp != '\0' && (*cp != '}' || depth > 0))
+- {
+- if (*cp == '}')
+- --depth;
+- ++cp;
+- }
+- if (*cp == '\0')
+- /* An incorrectly terminated brace expression. */
+- return NULL;
+
+- continue;
+- }
+- break;
+- }
++ while (*cp != '\0')
++ if ((flags & GLOB_NOESCAPE) == 0 && *cp == '\\')
++ {
++ if (*++cp == '\0')
++ break;
++ ++cp;
++ }
++ else
++ {
++ if ((*cp == '}' && depth-- == 0) || (*cp == ',' && depth == 0))
++ break;
++
++ if (*cp++ == '{')
++ depth++;
++ }
+
+- return cp;
++ return *cp != '\0' ? cp : NULL;
+ }
+
+ #endif /* !GLOB_ONLY_P */
+@@ -460,7 +437,30 @@
+
+ if (flags & GLOB_BRACE)
+ {
+- const char *begin = strchr (pattern, '{');
++ const char *begin;
++
++ if (flags & GLOB_NOESCAPE)
++ begin = strchr (pattern, '{');
++ else
++ {
++ begin = pattern;
++ while (1)
++ {
++ if (*begin == '\0')
++ {
++ begin = NULL;
++ break;
++ }
++
++ if (*begin == '\\' && begin[1] != '\0')
++ ++begin;
++ else if (*begin == '{')
++ break;
++
++ ++begin;
++ }
++ }
++
+ if (begin != NULL)
+ {
+ /* Allocate working buffer large enough for our work. Note that
+@@ -493,7 +493,7 @@
+
+ /* Find the first sub-pattern and at the same time find the
+ rest after the closing brace. */
+- next = next_brace_sub (begin + 1);
++ next = next_brace_sub (begin + 1, flags);
+ if (next == NULL)
+ {
+ /* It is an illegal expression. */
+@@ -507,7 +507,7 @@
+ rest = next;
+ while (*rest != '}')
+ {
+- rest = next_brace_sub (rest + 1);
++ rest = next_brace_sub (rest + 1, flags);
+ if (rest == NULL)
+ {
+ /* It is an illegal expression. */
+@@ -569,7 +569,7 @@
+ break;
+
+ p = next + 1;
+- next = next_brace_sub (p);
++ next = next_brace_sub (p, flags);
+ assert (next != NULL);
+ }
+
+@@ -797,7 +797,7 @@
+ # if !defined _AMIGA && !defined WINDOWS32
+ else
+ {
+- char *end_name = strchr (dirname, '/');
++ char *end_name = (char *) strchr (dirname, '/');
+ const char *user_name;
+ const char *home_dir;
+
+@@ -1174,6 +1174,7 @@
+ if (pglob->gl_pathv[pglob->gl_offs + i] != NULL)
+ free ((__ptr_t) pglob->gl_pathv[pglob->gl_offs + i]);
+ free ((__ptr_t) pglob->gl_pathv);
++ pglob->gl_pathv = NULL;
+ }
+ }
+
+--- proftpd.orig/tests/api/fsio.c
++++ proftpd/tests/api/fsio.c
+@@ -3926,28 +3926,35 @@
+ glob_t pglob;
+ int res;
+
++ mark_point();
+ res = pr_fs_glob(NULL, 0, NULL, NULL);
+ ck_assert_msg(res < 0, "Failed to handle null arguments");
+ ck_assert_msg(errno == EINVAL, "Expected EINVAL (%d), got %s (%d)", EINVAL,
+ strerror(errno), errno);
+
++ mark_point();
+ res = pr_fs_glob(NULL, 0, NULL, &pglob);
+ ck_assert_msg(res < 0, "Failed to handle null arguments");
+ ck_assert_msg(errno == EINVAL, "Expected EINVAL (%d), got %s (%d)", EINVAL,
+ strerror(errno), errno);
+
++ mark_point();
+ memset(&pglob, 0, sizeof(pglob));
+ res = pr_fs_glob("*", 0, NULL, &pglob);
+ ck_assert_msg(res == 0, "Failed to glob: glob(3) returned %d: %s", res,
+ strerror(errno));
+ ck_assert_msg(pglob.gl_pathc > 0, "Expected >0, got %lu",
+ (unsigned long) pglob.gl_pathc);
++ pr_fs_globfree(&pglob);
++
++ mark_point();
++ memset(&pglob, 0, sizeof(pglob));
++ res = pr_fs_glob("{a,", GLOB_NOSORT|GLOB_BRACE, NULL, &pglob);
++ ck_assert_msg(res == GLOB_NOMATCH, "Expected GLOB_NOMATCH, got %d", res);
++ pr_fs_globfree(&pglob);
+
+ mark_point();
+ pr_fs_globfree(NULL);
+- if (res == 0) {
+- pr_fs_globfree(&pglob);
+- }
+ }
+ END_TEST
+
+@@ -4948,6 +4955,7 @@
+ }
+ END_TEST
+
++#if defined(HAVE_STATFS_F_TYPE) || defined(HAVE_STATFS_F_FSTYPENAME)
+ START_TEST (fs_is_nfs_test) {
+ int res;
+
+@@ -4960,6 +4968,7 @@
+ ck_assert_msg(res == FALSE, "Expected FALSE, got %d", res);
+ }
+ END_TEST
++#endif /* HAVE_STATFS_F_TYPE or HAVE_STATFS_F_FSTYPENAME */
+
+ START_TEST (fs_valid_path_test) {
+ int res;
+@@ -5387,7 +5396,7 @@
+ tcase_add_test(testcase, fs_have_access_test);
+ #if defined(HAVE_STATFS_F_TYPE) || defined(HAVE_STATFS_F_FSTYPENAME)
+ tcase_add_test(testcase, fs_is_nfs_test);
+-#endif
++#endif /* HAVE_STATFS_F_TYPE or HAVE_STATFS_F_FSTYPENAME */
+ tcase_add_test(testcase, fs_valid_path_test);
+ tcase_add_test(testcase, fsio_smkdir_test);
+ tcase_add_test(testcase, fsio_getpipebuf_test);
=====================================
debian/patches/series
=====================================
@@ -17,3 +17,4 @@ odbc
c4515f5bd4236a803213c9df926e4094c4b003f2.diff
ab5c8cd35f85b75e90019a32674a1f1062268bec.diff
ceb22dcce086d9223269f9a0bfef21574cb9da60.diff
+549f81741f930acab56dfb4620c7603de05c20f2.diff
View it on GitLab: https://salsa.debian.org/debian-proftpd-team/proftpd/-/commit/220ccd4aa8823e79f79fe889e3c365a72f80e13c
--
View it on GitLab: https://salsa.debian.org/debian-proftpd-team/proftpd/-/commit/220ccd4aa8823e79f79fe889e3c365a72f80e13c
You're receiving this email because of your account on salsa.debian.org. Manage all notifications: https://salsa.debian.org/-/profile/notifications | Help: https://salsa.debian.org/help
More information about the Pkg-proftpd-maintainers
mailing list