[packages/pure-ftpd] Rel 2. Backport per-IP limit, PAM conversation and ftpwho XML fixes
arekm
arekm at pld-linux.org
Thu Oct 29 08:59:48 CET 2026
commit a40ce481177ad77a794a39af2b459ead7a878a05
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Oct 29 00:20:19 2026 +0100
Rel 2. Backport per-IP limit, PAM conversation and ftpwho XML fixes
pure-ftpd-ftpwho-xml-quotes.patch | 96 ++++++++++++++++++++++++++++++++++
pure-ftpd-iptrack-full-table.patch | 28 ++++++++++
pure-ftpd-pam-conv-indexing.patch | 103 +++++++++++++++++++++++++++++++++++++
pure-ftpd.spec | 16 ++++--
4 files changed, 239 insertions(+), 4 deletions(-)
---
diff --git a/pure-ftpd.spec b/pure-ftpd.spec
index 7032226..d3b2faf 100644
--- a/pure-ftpd.spec
+++ b/pure-ftpd.spec
@@ -9,7 +9,7 @@
%bcond_without tls # disable SSL/TLS support
%bcond_without cap # disable capabilities
-%define rel 1
+%define rel 2
Summary: Small, fast and secure FTP server
Summary(pl.UTF-8): Mały, szybki i bezpieczny serwer FTP
Name: pure-ftpd
@@ -38,9 +38,12 @@ Patch7: %{name}-mysql-utf8.patch
Patch8: caps.patch
Patch11: keep-spaces.patch
-URL: http://www.pureftpd.org/
-%{?with_extra:BuildRequires: autoconf >= 2.65}
-%{?with_extra:BuildRequires: automake >= 1:1.11.2}
+Patch12: %{name}-iptrack-full-table.patch
+Patch13: %{name}-pam-conv-indexing.patch
+Patch14: %{name}-ftpwho-xml-quotes.patch
+URL: https://www.pureftpd.org/
+BuildRequires: autoconf >= 2.65
+BuildRequires: automake >= 1:1.11.2
BuildRequires: libapparmor-devel
%{?with_cap:BuildRequires: libcap-devel}
%{?with_extra:BuildRequires: libcfg+-devel >= 0.6.2}
@@ -120,6 +123,9 @@ Ten pakiet zawiera schemat Pure-FTPd pureftpd.schema dla openldapa.
%patch -P8 -p1
%patch -P11 -p1
+%patch -P12 -p1
+%patch -P13 -p1
+%patch -P14 -p1
%{?with_extra:%patch -P2 -p1}
@@ -173,6 +179,8 @@ install -d $RPM_BUILD_ROOT/etc/{pam.d,sysconfig,security,rc.d/init.d,%{name}/{ce
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
+%{__rm} -r $RPM_BUILD_ROOT%{_docdir}/%{name}
+
cp -p %{SOURCE1} $RPM_BUILD_ROOT/etc/pam.d/%{name}
install -p %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name}
cp -p %{SOURCE3} $RPM_BUILD_ROOT/etc/sysconfig/%{name}
diff --git a/pure-ftpd-ftpwho-xml-quotes.patch b/pure-ftpd-ftpwho-xml-quotes.patch
new file mode 100644
index 0000000..901143f
--- /dev/null
+++ b/pure-ftpd-ftpwho-xml-quotes.patch
@@ -0,0 +1,96 @@
+From 4213de72ce45a6095d658c61e446c6fac07b1579 Mon Sep 17 00:00:00 2001
+From: Fabian Wahle <fabian at nash.io>
+Date: Thu, 18 Jun 2026 22:58:09 +0200
+Subject: [PATCH] fix: escape single and double quotes in pure-ftpwho XML
+ output
+
+Account and filename values are emitted inside double-quoted XML
+attributes. Unescaped quotes break the XML feed and can poison downstream
+parsers. Escape both ' and " to produce well-formed XML.
+
+CWE-116: Improper Encoding or Escaping of Output
+---
+ src/pure-ftpwho.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/src/pure-ftpwho.c b/src/pure-ftpwho.c
+index 4ef93c76..628d23f9 100644
+--- a/src/pure-ftpwho.c
++++ b/src/pure-ftpwho.c
+@@ -248,6 +248,24 @@ static char *xml_escaped(const char *const s_) {
+ *bufpnt++ = ';';
+ left -= sizeof "&" - (size_t) 1U;
+ break;
++ case '\'':
++ if (left < sizeof "'" - (size_t) 1U) {
++ *bufpnt = 0;
++ return buf;
++ }
++ *bufpnt++ = '&'; *bufpnt++ = 'a'; *bufpnt++ = 'p'; *bufpnt++ = 'o';
++ *bufpnt++ = 's'; *bufpnt++ = ';';
++ left -= sizeof "'" - (size_t) 1U;
++ break;
++ case '"':
++ if (left < sizeof """ - (size_t) 1U) {
++ *bufpnt = 0;
++ return buf;
++ }
++ *bufpnt++ = '&'; *bufpnt++ = 'q'; *bufpnt++ = 'u'; *bufpnt++ = 'o';
++ *bufpnt++ = 't'; *bufpnt++ = ';';
++ left -= sizeof """ - (size_t) 1U;
++ break;
+ default:
+ *bufpnt++ = (char) *s;
+ left--;
+From 50c76627f250bf533cdf483b98a9ddcd1f6d5816 Mon Sep 17 00:00:00 2001
+From: Frank Denis <github at pureftpd.org>
+Date: Fri, 19 Jun 2026 15:23:13 +0200
+Subject: [PATCH] No need to escape ' in duble-quoted strings
+
+---
+ src/pure-ftpwho.c | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+diff --git a/src/pure-ftpwho.c b/src/pure-ftpwho.c
+index 628d23f9..d664d6dd 100644
+--- a/src/pure-ftpwho.c
++++ b/src/pure-ftpwho.c
+@@ -248,15 +248,6 @@ static char *xml_escaped(const char *const s_) {
+ *bufpnt++ = ';';
+ left -= sizeof "&" - (size_t) 1U;
+ break;
+- case '\'':
+- if (left < sizeof "'" - (size_t) 1U) {
+- *bufpnt = 0;
+- return buf;
+- }
+- *bufpnt++ = '&'; *bufpnt++ = 'a'; *bufpnt++ = 'p'; *bufpnt++ = 'o';
+- *bufpnt++ = 's'; *bufpnt++ = ';';
+- left -= sizeof "'" - (size_t) 1U;
+- break;
+ case '"':
+ if (left < sizeof """ - (size_t) 1U) {
+ *bufpnt = 0;
+From 3097dd7841dd65952bf37c474f182e342760e2d2 Mon Sep 17 00:00:00 2001
+From: Frank Denis <github at pureftpd.org>
+Date: Wed, 28 Oct 2026 02:48:15 +0100
+Subject: [PATCH] Adjust buffer size for XML escaped values to avoid truncation
+
+---
+ src/pure-ftpwho.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/pure-ftpwho.c b/src/pure-ftpwho.c
+index 568e4abc..0c5df35d 100644
+--- a/src/pure-ftpwho.c
++++ b/src/pure-ftpwho.c
+@@ -207,7 +207,8 @@ static void text_output_footer(void)
+ }
+
+ static char *xml_escaped(const char *const s_) {
+- static char buf[PATH_MAX + 32U];
++ static char buf[(sizeof(FTPWhoEntry) + NI_MAXHOST + NI_MAXSERV) *
++ (sizeof """ - 1U)];
+ const unsigned char *s = (const unsigned char *) s_;
+ char *bufpnt = buf;
+ size_t left = sizeof buf - (size_t) 1U;
diff --git a/pure-ftpd-iptrack-full-table.patch b/pure-ftpd-iptrack-full-table.patch
new file mode 100644
index 0000000..9b8c43e
--- /dev/null
+++ b/pure-ftpd-iptrack-full-table.patch
@@ -0,0 +1,28 @@
+From 5008fcaac7432c34803335c67356d9e6d15bbbe9 Mon Sep 17 00:00:00 2001
+From: Frank Denis <github at pureftpd.org>
+Date: Tue, 28 Apr 2026 11:02:13 +0200
+Subject: [PATCH] Prperly handle per-IP connection limits when the table is
+ full
+
+Once the internal IP tracking table filled up, every new connection
+from an already-tracked address evicted the oldest entry instead of
+reusing the existing one.
+
+Reported by COCOP1l0t, thanks!
+---
+ src/dynamic.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/dynamic.c b/src/dynamic.c
+index 744de906..b555ad85 100644
+--- a/src/dynamic.c
++++ b/src/dynamic.c
+@@ -42,7 +42,7 @@ static unsigned int iptrack_find_ip_or_shift
+
+ do {
+ if (iptrack_list[c].pid != (pid_t) 0 &&
+- STORAGE_FAMILY(iptrack_list[c].ip) != STORAGE_FAMILY(*ip)) {
++ STORAGE_FAMILY(iptrack_list[c].ip) == STORAGE_FAMILY(*ip)) {
+ if (STORAGE_FAMILY(iptrack_list[c].ip) == AF_INET &&
+ STORAGE_SIN_ADDR_CONST(iptrack_list[c].ip) == STORAGE_SIN_ADDR_CONST(*ip)) {
+ return c;
diff --git a/pure-ftpd-pam-conv-indexing.patch b/pure-ftpd-pam-conv-indexing.patch
new file mode 100644
index 0000000..86ecffd
--- /dev/null
+++ b/pure-ftpd-pam-conv-indexing.patch
@@ -0,0 +1,103 @@
+From dfecbcc2e5ee8f42d4ead5beac4814f83f2d4837 Mon Sep 17 00:00:00 2001
+From: Frank Denis <github at pureftpd.org>
+Date: Sat, 19 Sep 2026 15:56:55 +0200
+Subject: [PATCH] Fix PAM response indexing for mixed conversations
+
+---
+ src/log_pam.c | 50 +++++++++++++++++++++++---------------------------
+ 1 file changed, 23 insertions(+), 27 deletions(-)
+
+diff --git a/src/log_pam.c b/src/log_pam.c
+index 22757824..1c6bc9d2 100644
+--- a/src/log_pam.c
++++ b/src/log_pam.c
+@@ -69,66 +69,62 @@ static int PAM_error;
+ * echo off means password.
+ */
+
+-#define GET_MEM \
+- size += sizeof(struct pam_response); \
+- if ((reply = realloc(reply, size)) == NULL) { \
+- PAM_error = 1; \
+- return PAM_CONV_ERR; \
+- }
+-
+ static int PAM_conv(int num_msg,
+ const struct pam_message **msg,
+ struct pam_response **resp, void *appdata_ptr)
+ {
+ int count = 0;
+- unsigned int replies = 0U;
+ struct pam_response *reply = NULL;
+- size_t size = (size_t) 0U;
+
+ (void) appdata_ptr;
+ *resp = NULL;
++ if (num_msg <= 0 ||
++ (reply = calloc((size_t) num_msg, sizeof *reply)) == NULL) {
++ PAM_error = 1;
++ return PAM_CONV_ERR;
++ }
+ for (count = 0; count < num_msg; count++) {
+ switch (msg[count]->msg_style) {
+ case PAM_PROMPT_ECHO_ON:
+- GET_MEM;
+- memset(&reply[replies], 0, sizeof reply[replies]);
+- if ((reply[replies].resp = strdup(PAM_username)) == NULL) {
++ if ((reply[count].resp = strdup(PAM_username)) == NULL) {
+ #ifdef PAM_BUF_ERR
+- reply[replies].resp_retcode = PAM_BUF_ERR;
++ reply[count].resp_retcode = PAM_BUF_ERR;
+ #endif
+- PAM_error = 1;
+- return PAM_CONV_ERR;
++ goto error;
+ }
+- reply[replies++].resp_retcode = PAM_SUCCESS;
++ reply[count].resp_retcode = PAM_SUCCESS;
+ /* PAM frees resp */
+ break;
+ case PAM_PROMPT_ECHO_OFF:
+- GET_MEM;
+- memset(&reply[replies], 0, sizeof reply[replies]);
+- if ((reply[replies].resp = strdup(PAM_password)) == NULL) {
++ if ((reply[count].resp = strdup(PAM_password)) == NULL) {
+ #ifdef PAM_BUF_ERR
+- reply[replies].resp_retcode = PAM_BUF_ERR;
++ reply[count].resp_retcode = PAM_BUF_ERR;
+ #endif
+- PAM_error = 1;
+- return PAM_CONV_ERR;
++ goto error;
+ }
+- reply[replies++].resp_retcode = PAM_SUCCESS;
++ reply[count].resp_retcode = PAM_SUCCESS;
+ /* PAM frees resp */
+ break;
++ case PAM_ERROR_MSG:
+ case PAM_TEXT_INFO:
+ /* ignore it... */
+ break;
+- case PAM_ERROR_MSG:
+ default:
+ /* Must be an error of some sort... */
+- free(reply);
+- PAM_error = 1;
+- return PAM_CONV_ERR;
++ goto error;
+ }
+ }
+ *resp = reply;
+
+ return PAM_SUCCESS;
++
++ error:
++ while (count > 0) {
++ free(reply[--count].resp);
++ }
++ free(reply);
++ PAM_error = 1;
++ return PAM_CONV_ERR;
+ }
+
+ /* Solaris throws warning about incompatible pointer types, it does not
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/pure-ftpd.git/commitdiff/a40ce481177ad77a794a39af2b459ead7a878a05
More information about the pld-cvs-commit
mailing list