[Alpine-info] bugfixes for UTF-8 hostnames
Mark Crispin
markrcrispin at live.com
Wed Sep 24 15:32:45 PDT 2008
Problem:
Invalid email headers generated by Alpine.
Diagnosis:
Alpine assumes that hostname() always returns ASCII.
Some system (e.g., iPhone) return UTF-8.
Solution:
Attached patches to alpine-2.00/pith/osdep/domnames.c and
alpine-2.00/pith/osdep/hostname.c
I came up with these patches when I was still at UW, but they never made it in
to the UW sources. Now that UW is no longer working on Alpine, someone in the
community should install them.
And yes, I do have Alpine running on iPhone/iPod Touch.
-- Mark --
http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
-------------- next part --------------
*** domnames.c.OLD Mon May 19 14:18:23 2008
--- domnames.c Mon May 19 14:21:28 2008
***************
*** 51,57 ****
char **alias;
char *maybe = NULL;
! gethostname(hname, MAX_ADDRESS);
he = gethostbyname(hname);
hostname[0] = '\0';
--- 51,70 ----
char **alias;
char *maybe = NULL;
! if (gethostname(hname, MAX_ADDRESS)) hname[0] = 0xff;
! /* sanity check of hostname string */
! for (dn = hname; (*dn > 0x20) && (*dn < 0x7f); ++dn);
! if (*dn) { /* only if invalid string returned */
! #if 0
! hostname[0] = domainname[0] = '\0';
! #else
! /* Contrary to the comments above, the UNIX code does not expect
! these strings to be blank.
! */
! strcpy (hostname, (strcpy (domainname,"unknown")));
! #endif
! return;
! }
he = gethostbyname(hname);
hostname[0] = '\0';
-------------- next part --------------
*** hostname.c.OLD Mon May 19 14:18:24 2008
--- hostname.c Mon May 19 14:21:23 2008
***************
*** 47,53 ****
{
#if HAVE_GETHOSTNAME
! return(gethostname(hostname, size));
#elif HAVE_UNAME
--- 47,57 ----
{
#if HAVE_GETHOSTNAME
! if(gethostname(hostname, size)) return -1;
! /* sanity check of hostname string */
! for (*dn = hname; (*dn > 0x20) && (*dn < 0x7f); ++dn);
! if (*dn) strcpy (hostname,"unknown");
! return 0;
#elif HAVE_UNAME
More information about the Alpine-info
mailing list