summaryrefslogtreecommitdiff
path: root/fdm
diff options
context:
space:
mode:
Diffstat (limited to 'fdm')
-rw-r--r--fdm/0001-Fix-bugs-in-PCRE2-code-don-t-walk-off-the-end-of-the.patch80
-rw-r--r--fdm/0002-Fix-use-after-free-GitHub-issue-126.patch26
-rw-r--r--fdm/0003-Replace-obsolete-macros-AC_HELP_STRING-and-AC_TRY_LI.patch86
-rw-r--r--fdm/0004-Send-UTF8-command-to-POP3-server-ignore-the-response.patch50
-rw-r--r--fdm/APKBUILD47
5 files changed, 289 insertions, 0 deletions
diff --git a/fdm/0001-Fix-bugs-in-PCRE2-code-don-t-walk-off-the-end-of-the.patch b/fdm/0001-Fix-bugs-in-PCRE2-code-don-t-walk-off-the-end-of-the.patch
new file mode 100644
index 0000000..9c383b9
--- /dev/null
+++ b/fdm/0001-Fix-bugs-in-PCRE2-code-don-t-walk-off-the-end-of-the.patch
@@ -0,0 +1,80 @@
+From f1ec1982725d60045c0d871f3e613f2880046c22 Mon Sep 17 00:00:00 2001
+From: Nicholas Marriott <nicholas.marriott@gmail.com>
+Date: Wed, 1 Feb 2023 15:31:30 +0000
+Subject: [PATCH 1/4] Fix bugs in PCRE2 code - don't walk off the end of the
+ match list if NOMATCH is returned, and don't stop on empty matches. From
+ Thomas Hurst.
+
+---
+ pcre.c | 45 ++++++++++++++++++++++++++-------------------
+ 1 file changed, 26 insertions(+), 19 deletions(-)
+
+diff --git a/pcre.c b/pcre.c
+index e9a7f84..8d53532 100644
+--- a/pcre.c
++++ b/pcre.c
+@@ -66,7 +66,7 @@ int
+ re_block(struct re *re, const void *buf, size_t len, struct rmlist *rml,
+ char **cause)
+ {
+- int res;
++ int res, ret;
+ pcre2_match_data *pmd;
+ PCRE2_SIZE *ovector;
+ u_int i, j;
+@@ -85,27 +85,34 @@ re_block(struct re *re, const void *buf, size_t len, struct rmlist *rml,
+ }
+
+ pmd = pcre2_match_data_create_from_pattern(re->pcre2, NULL);
+- res = pcre2_match(re->pcre2, buf, len, 0, 0, pmd, NULL);
+- if (res < 0 && res != PCRE2_ERROR_NOMATCH) {
+- xasprintf(cause, "%s: regexec failed", re->str);
+- pcre2_match_data_free(pmd);
+- return (-1);
+- }
++ if (pmd == NULL)
++ fatalx("pcre2_match_data_create_from_pattern failed");
+
+- if (rml != NULL) {
+- ovector = pcre2_get_ovector_pointer(pmd);
+- for (i = 0; i < res; i++) {
+- j = i * 2;
+- if (ovector[j + 1] <= ovector[j])
+- break;
+- rml->list[i].valid = 1;
+- rml->list[i].so = ovector[j];
+- rml->list[i].eo = ovector[j + 1];
++ res = pcre2_match(re->pcre2, buf, len, 0, 0, pmd, NULL);
++ if (res > 0) {
++ if (rml != NULL) {
++ if (res > NPMATCH)
++ res = NPMATCH;
++ ovector = pcre2_get_ovector_pointer(pmd);
++ for (i = 0; i < res; i++) {
++ j = i * 2;
++ if (ovector[j + 1] < ovector[j])
++ break;
++ rml->list[i].valid = 1;
++ rml->list[i].so = ovector[j];
++ rml->list[i].eo = ovector[j + 1];
++ }
++ rml->valid = 1;
+ }
+- rml->valid = 1;
++ ret = 1;
++ } else if (res == PCRE2_ERROR_NOMATCH)
++ ret = 0;
++ else {
++ xasprintf(cause, "%s: regexec failed", re->str);
++ ret = -1;
+ }
+-
+- return (res != PCRE2_ERROR_NOMATCH);
++ pcre2_match_data_free(pmd);
++ return (ret);
+ }
+
+ void
+--
+2.42.0
+
diff --git a/fdm/0002-Fix-use-after-free-GitHub-issue-126.patch b/fdm/0002-Fix-use-after-free-GitHub-issue-126.patch
new file mode 100644
index 0000000..617d81b
--- /dev/null
+++ b/fdm/0002-Fix-use-after-free-GitHub-issue-126.patch
@@ -0,0 +1,26 @@
+From 028f59bef0ea9435fb8fbe095b2939652ce63479 Mon Sep 17 00:00:00 2001
+From: Nicholas Marriott <nicholas.marriott@gmail.com>
+Date: Mon, 3 Apr 2023 08:54:28 +0100
+Subject: [PATCH 2/4] Fix use-after-free, GitHub issue 126.
+
+---
+ connect.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/connect.c b/connect.c
+index 1dc5db9..da8013e 100644
+--- a/connect.c
++++ b/connect.c
+@@ -550,8 +550,8 @@ httpproxy(struct server *srv,
+ if (strlen(line) < 12 ||
+ strncmp(line, "HTTP/", 5) != 0 ||
+ strncmp(line + 8, " 200", 4) != 0) {
+- xfree(line);
+ xasprintf(cause, "unexpected data: %s", line);
++ xfree(line);
+ return (-1);
+ }
+ header = 1;
+--
+2.42.0
+
diff --git a/fdm/0003-Replace-obsolete-macros-AC_HELP_STRING-and-AC_TRY_LI.patch b/fdm/0003-Replace-obsolete-macros-AC_HELP_STRING-and-AC_TRY_LI.patch
new file mode 100644
index 0000000..2e0e288
--- /dev/null
+++ b/fdm/0003-Replace-obsolete-macros-AC_HELP_STRING-and-AC_TRY_LI.patch
@@ -0,0 +1,86 @@
+From 96b4e4369d48a828bd2de4bf76c78c64a15f571e Mon Sep 17 00:00:00 2001
+From: Nicholas Marriott <nicholas.marriott@gmail.com>
+Date: Wed, 21 Jun 2023 07:36:46 +0100
+Subject: [PATCH 3/4] Replace obsolete macros AC_HELP_STRING and AC_TRY_LINK,
+ from Aaron Ji.
+
+---
+ configure.ac | 21 +++++++++++++--------
+ 1 file changed, 13 insertions(+), 8 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index e356e9c..4b1d6fe 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -24,14 +24,14 @@ test "$localstatedir" = '${prefix}/var' && localstatedir=/var
+
+ AC_ARG_ENABLE(
+ debug,
+- AC_HELP_STRING(--enable-debug, create a debug build),
++ AS_HELP_STRING(--enable-debug, create a debug build),
+ found_debug=$enable_debug
+ )
+ AM_CONDITIONAL(IS_DEBUG, test "x$found_debug" = xyes)
+
+ AC_ARG_ENABLE(
+ static,
+- AC_HELP_STRING(--enable-static, create a static build),
++ AS_HELP_STRING(--enable-static, create a static build),
+ found_static=$enable_static
+ )
+ if test "x$found_static" = xyes; then
+@@ -40,7 +40,7 @@ fi
+
+ AC_ARG_ENABLE(
+ pcre2,
+- AC_HELP_STRING(--enable-pcre2, use PCRE2),
++ AS_HELP_STRING(--enable-pcre2, use PCRE2),
+ found_pcre2=$enable_pcre2
+ )
+ if test "x$found_pcre2" = xyes; then
+@@ -143,13 +143,15 @@ fi
+ AM_CONDITIONAL(NO_STRTONUM, [test "x$found_strtonum" = xno])
+
+ AC_MSG_CHECKING(for b64_ntop)
+-AC_TRY_LINK(
++AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <resolv.h>
+ ],
+- [b64_ntop(NULL, 0, NULL, 0);],
++ [
++ b64_ntop(NULL, 0, NULL, 0);
++ ])],
+ found_b64_ntop=yes,
+ found_b64_ntop=no
+ )
+@@ -158,13 +160,15 @@ if test "x$found_b64_ntop" = xno; then
+
+ AC_MSG_CHECKING(for b64_ntop with -lresolv)
+ LIBS="$LIBS -lresolv"
+- AC_TRY_LINK(
++ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [
+ #include <sys/types.h>
+ #include <netinet/in.h>
+ #include <resolv.h>
+ ],
+- [b64_ntop(NULL, 0, NULL, 0);],
++ [
++ b64_ntop(NULL, 0, NULL, 0);
++ ])],
+ found_b64_ntop=yes,
+ found_b64_ntop=no
+ )
+@@ -178,4 +182,5 @@ if test "x$found_b64_ntop" = xyes; then
+ fi
+ AM_CONDITIONAL(NO_B64_NTOP, [test "x$found_b64_ntop" = xno])
+
+-AC_OUTPUT(Makefile)
++AC_CONFIG_FILES(Makefile)
++AC_OUTPUT
+--
+2.42.0
+
diff --git a/fdm/0004-Send-UTF8-command-to-POP3-server-ignore-the-response.patch b/fdm/0004-Send-UTF8-command-to-POP3-server-ignore-the-response.patch
new file mode 100644
index 0000000..07aaf27
--- /dev/null
+++ b/fdm/0004-Send-UTF8-command-to-POP3-server-ignore-the-response.patch
@@ -0,0 +1,50 @@
+From 0918b78a82a789d63cebe44b7662f0a8dc603000 Mon Sep 17 00:00:00 2001
+From: Nicholas Marriott <nicholas.marriott@gmail.com>
+Date: Mon, 4 Sep 2023 09:03:47 +0100
+Subject: [PATCH 4/4] Send UTF8 command to POP3 server (ignore the response),
+ because some servers don't like UTF-8 without it.
+
+---
+ pop3-common.c | 19 +++++++++++++++++++
+ 1 file changed, 19 insertions(+)
+
+diff --git a/pop3-common.c b/pop3-common.c
+index 0724887..e038172 100644
+--- a/pop3-common.c
++++ b/pop3-common.c
+@@ -54,6 +54,7 @@ int pop3_invalid(struct account *, const char *);
+ int pop3_state_connect(struct account *, struct fetch_ctx *);
+ int pop3_state_starttls(struct account *, struct fetch_ctx *);
+ int pop3_state_connected(struct account *, struct fetch_ctx *);
++int pop3_state_utf8(struct account *, struct fetch_ctx *);
+ int pop3_state_user(struct account *, struct fetch_ctx *);
+ int pop3_state_cache1(struct account *, struct fetch_ctx *);
+ int pop3_state_cache2(struct account *, struct fetch_ctx *);
+@@ -436,6 +437,24 @@ pop3_state_connected(struct account *a, struct fetch_ctx *fctx)
+ }
+ }
+
++ if (pop3_putln(a, "UTF8") != 0)
++ return (FETCH_ERROR);
++ fctx->state = pop3_state_utf8;
++ return (FETCH_BLOCK);
++}
++
++/* UTF8 state. */
++int
++pop3_state_utf8(struct account *a, struct fetch_ctx *fctx)
++{
++ struct fetch_pop3_data *data = a->data;
++ char *line;
++
++ if (pop3_getln(a, fctx, &line) != 0)
++ return (FETCH_ERROR);
++ if (line == NULL)
++ return (FETCH_BLOCK);
++
+ if (pop3_putln(a, "USER %s", data->user) != 0)
+ return (FETCH_ERROR);
+ fctx->state = pop3_state_user;
+--
+2.42.0
+
diff --git a/fdm/APKBUILD b/fdm/APKBUILD
new file mode 100644
index 0000000..f2b604d
--- /dev/null
+++ b/fdm/APKBUILD
@@ -0,0 +1,47 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=fdm
+pkgver=2.2
+pkgrel=2
+pkgdesc="A simple lightweight tool of fetching, filtering and delivering emails"
+url="https://github.com/nicm/fdm"
+arch="all"
+license="ISC"
+makedepends="
+ openssl-dev>3
+ pcre2-dev
+ tdb-dev
+ zlib-dev
+ "
+subpackages="$pkgname-doc"
+source="https://github.com/nicm/fdm/releases/download/$pkgver/fdm-$pkgver.tar.gz
+ 0001-Fix-bugs-in-PCRE2-code-don-t-walk-off-the-end-of-the.patch
+ 0002-Fix-use-after-free-GitHub-issue-126.patch
+ 0004-Send-UTF8-command-to-POP3-server-ignore-the-response.patch
+"
+build() {
+ CFLAGS="$CFLAGS -flto=auto" \
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --localstatedir=/var \
+ --enable-pcre2
+ make
+}
+
+check() {
+ make check
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+}
+
+sha512sums="
+13efa0f272c5f6146b90e094602e8a9b52016af79ae0b6cd80dc9f36b2ba37f64cadae7313bd8db90bcb007dd07206a3614987f11bb82c3535e04f0511c9fc6d fdm-2.2.tar.gz
+12bb3cd5d5365c5811f6a165596d1ff08974dcef81f4529acfa366a0d90a8f26904b704622c16ceb56c4c0a790c8bb47f1b63c5bcf01e6bc78008c03a07a2a28 0001-Fix-bugs-in-PCRE2-code-don-t-walk-off-the-end-of-the.patch
+f04d61f89ba1bdbc390cc34c50d3ee748fe3cb8746925925bfeb353b0b09feb678d10730e735797592d5fa013d41bcf941770bd8f26f342e7664d339d5a3e16d 0002-Fix-use-after-free-GitHub-issue-126.patch
+b17cd601611fdfc4d47282b7846eba225cd76950c81b1f410ebea604900d9571703af4d8e45e31edcf5a50ced7b8ca978ce4ca71ce806cf69732100ac7c301df 0004-Send-UTF8-command-to-POP3-server-ignore-the-response.patch
+"