This is for Bug# 3298. Patch attached. I don't use mercurial so this is a context diff against whatever version I had locally at the time. I don't think there have been many changes to that code since then, so I expect it should apply cleanly. See additional notes in the bug. -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
diff -uNr mutt-1.5.20hg/addrinfo.h mutt-1.5.20hg.patched/addrinfo.h
--- mutt-1.5.20hg/addrinfo.h 1969-12-31 19:00:00.000000000 -0500
+++ mutt-1.5.20hg.patched/addrinfo.h 2009-08-18 11:25:52.000000000 -0400
@@ -0,0 +1,30 @@
+
+/*
+ * Copyright © 2009 Derek Martin <code@xxxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of the GNU General Public License as published by the Free
Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+struct addrinfo {
+ int ai_flags;
+ int ai_family;
+ int ai_socktype;
+ int ai_protocol;
+ size_t ai_addrlen;
+ struct sockaddr *ai_addr;
+ char *ai_canonname;
+ struct addrinfo *ai_next;
+}
+
diff -uNr mutt-1.5.20hg/configure.ac mutt-1.5.20hg.patched/configure.ac
--- mutt-1.5.20hg/configure.ac 2009-07-28 03:00:05.000000000 -0400
+++ mutt-1.5.20hg.patched/configure.ac 2009-08-18 11:30:10.000000000 -0400
@@ -345,6 +345,7 @@
AC_REPLACE_FUNCS([setenv strcasecmp strdup strsep strtok_r wcscasecmp])
AC_REPLACE_FUNCS([strcasestr mkdtemp])
+AC_REPLACE_FUNCS([getaddrinfo freeaddrinfo])
AC_CHECK_FUNC(getopt)
if test $ac_cv_func_getopt = yes; then
diff -uNr mutt-1.5.20hg/freeaddrinfo.c mutt-1.5.20hg.patched/freeaddrinfo.c
--- mutt-1.5.20hg/freeaddrinfo.c 1969-12-31 19:00:00.000000000 -0500
+++ mutt-1.5.20hg.patched/freeaddrinfo.c 2009-08-18 11:29:37.000000000
-0400
@@ -0,0 +1,35 @@
+/*
+ * Copyright © 2009 Derek Martin <code@xxxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of the GNU General Public License as published by the Free
Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#if HAVE_CONFIG_H
+/*# include "config.h" */
+#endif
+
+/* Check for getaddrinfo() because if we have it, the types are defined. */
+#ifndef HAVE_GETADDRINFO
+#include "addrinfo.h"
+#endif
+
+#include "mutt.h"
+
+void freeaddrinfo(struct addrinfo *res)
+{
+ safe_free (res->ai_canonname);
+ safe_free (res);
+}
+
diff -uNr mutt-1.5.20hg/getaddrinfo.c mutt-1.5.20hg.patched/getaddrinfo.c
--- mutt-1.5.20hg/getaddrinfo.c 1969-12-31 19:00:00.000000000 -0500
+++ mutt-1.5.20hg.patched/getaddrinfo.c 2009-08-18 11:31:53.000000000 -0400
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2009 Derek Martin <code@xxxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify it
under
+ * the terms of the GNU General Public License as published by the Free
Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#if HAVE_CONFIG_H
+/*# include "config.h" */
+#endif
+
+#include <string.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "addrinfo.h"
+#include "mutt.h"
+
+/*
+ * this implementation of getaddrinfo() is only intended to be a wrapper around
+ * gethostbyname(), for unfortunate implementations that lack getadrinfo().
You
+ * must pass it a node name, the service must be NULL, the hints feild is
+ * ignored, and the result will only ever have one struct.
+ */
+
+int getaddrinfo (const char *node,
+ const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **res)
+{
+ struct addrinfo *r;
+ struct hostent *h;
+
+ if (!(r = (struct addrinfo *)safe_malloc(sizeof (struct addrinfo))))
+ return -1;
+ r->ai_flags = 0;
+ r->ai_family = AF_INET;
+ r->ai_socktype = 0;
+ r->ai_protocol = 0;
+ r->ai_addrlen = 0;
+ r->ai_addr = NULL;
+ r->ai_next = NULL;
+
+ if (!(h = gethostbyname(node))) return -1;
+ r->ai_canonname = safe_strdup(h->h_name);
+ *res = r;
+ return 0;
+}
+
+
diff -uNr mutt-1.5.20hg/getdomain.c mutt-1.5.20hg.patched/getdomain.c
--- mutt-1.5.20hg/getdomain.c 2007-05-29 03:00:07.000000000 -0400
+++ mutt-1.5.20hg.patched/getdomain.c 2009-08-18 11:51:09.000000000 -0400
@@ -1,68 +1,59 @@
+/*
+ * Copyright © 2009 Derek Martin <code@xxxxxxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
+ */
+
#if HAVE_CONFIG_H
# include "config.h"
#endif
-#include <stdio.h>
-#include <ctype.h>
#include <string.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
-#include "mutt.h"
-
-#ifndef STDC_HEADERS
-int fclose ();
+#ifndef HAVE_GETADDRINFO
+#include "addrinfo.h"
#endif
-/* poor man's version of getdomainname() for systems where it does not return
- * return the DNS domain, but the NIS domain.
- */
+#include "mutt.h"
+
+/* A DNS name can actually be only 253 octets, but whatever... */
+#define MAXHN 256
-static void strip_trailing_dot (char *q)
+int getdnsdomainname (char *d, size_t len)
{
- char *p = q;
-
- for (; *q; q++)
- p = q;
-
- if (*p == '.')
- *p = '\0';
+ char node[MAXHN];
+ struct addrinfo hints;
+ struct addrinfo *h;
+ char *p;
+
+ *d = '\0';
+ memset(&hints, 0, sizeof (struct addrinfo));
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_family = AF_UNSPEC;
+
+ if (gethostname(node, MAXHN)) return -1;
+ if (getaddrinfo(node, NULL, &hints, &h)) return -1;
+ if (!(p = strchr(h->ai_canonname, '.'))) return -1;
+ strfcpy(d, ++p, len);
+ freeaddrinfo(h);
+ return 0;
}
-int getdnsdomainname (char *s, size_t l)
-{
- FILE *f;
- char tmp[1024];
- char *p = NULL;
- char *q;
-
- if ((f = fopen ("/etc/resolv.conf", "r")) == NULL) return (-1);
-
- tmp[sizeof (tmp) - 1] = 0;
-
- l--; /* save room for the terminal \0 */
-
- while (fgets (tmp, sizeof (tmp) - 1, f) != NULL)
- {
- p = tmp;
- while (ISSPACE (*p)) p++;
- if (mutt_strncmp ("domain", p, 6) == 0 || mutt_strncmp ("search", p, 6) ==
0)
- {
- p += 6;
-
- for (q = strtok (p, " \t\n"); q; q = strtok (NULL, " \t\n"))
- if (strcmp (q, "."))
- break;
-
- if (q)
- {
- strip_trailing_dot (q);
- strfcpy (s, q, l);
- safe_fclose (&f);
- return 0;
- }
-
- }
- }
- safe_fclose (&f);
- return (-1);
-}
+
diff -uNr mutt-1.5.20hg/init.c mutt-1.5.20hg.patched/init.c
--- mutt-1.5.20hg/init.c 2009-07-29 03:00:04.000000000 -0400
+++ mutt-1.5.20hg.patched/init.c 2009-08-18 11:55:43.000000000 -0400
@@ -2927,7 +2927,7 @@
#ifndef DOMAIN
#define DOMAIN buffer
if (!p && getdnsdomainname (buffer, sizeof (buffer)) == -1)
- Fqdn = safe_strdup ("@");
+ Fqdn = safe_strdup (Hostname);
else
#endif /* DOMAIN */
if (*DOMAIN != '@')
diff -uNr mutt-1.5.20hg/protos.h mutt-1.5.20hg.patched/protos.h
--- mutt-1.5.20hg/protos.h 2009-07-24 03:00:08.000000000 -0400
+++ mutt-1.5.20hg.patched/protos.h 2009-08-18 11:38:51.000000000 -0400
@@ -554,3 +554,12 @@
#ifndef HAVE_MKDTEMP
char *mkdtemp (char *tmpl);
#endif
+
+#ifndef HAVE_GETADDRINFO
+#include "addrinfo.h"
+int getaddrinfo (const char *, const char *, const struct addrinfo *, struct
addrinfo **);
+#endif
+
+#ifndef HAVE_FREEADDRINFO
+void freeaddrinfo(struct addrinfo *);
+#endif
Attachment:
pgpthm2IQGZWM.pgp
Description: PGP signature