The attached patch should fix the crash. envelope is special in that it
can take the value STRING_DISABLED == (char *)-1 for "no envelope", and
the optmerge() function did not take this into account and tried to
strdup(-1).

This will likely become part of a future 6.4.22 and 6.5.0 release.


diff --git a/fetchmail.c b/fetchmail.c
index ac8e4607..71ecc1b0 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -996,7 +996,7 @@ static void optmerge(struct query *h2, struct query *h1, int force)
     list_merge(&h2->antispam, &h1->antispam, force);

 #define   FLAG_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld; } while (0)
-#define STRING_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) { if (h2->fld) free((void *)h2->fld), h2->fld = 0; if (h1->fld) h2->fld = xstrdup(h1->fld); } } while (0)
+#define STRING_MERGE(fld) do { if (force ? !!h1->fld : !h2->fld) { if (h2->fld) free((void *)h2->fld), h2->fld = 0; if (h1->fld) { if (h1->fld != STRING_DISABLED) h2->fld = xstrdup(h1->fld); else h2->fld = STRING_DISABLED; } } } while (0)
     STRING_MERGE(server.via);
     FLAG_MERGE(server.protocol);
     STRING_MERGE(server.service);

Reply via email to