Changeset 3545:31c0da584780

Show
Ignore:
Timestamp:
2003-12-29 03:37:41 (5 years ago)
Author:
Patrick Welche <prlw1@…>
Branch:
HEAD
Message:

A while ago I posted a similar patch which is necessary as when mutt
tries to connect to an imap server over ipv6 it stores the address
in a sockaddr which may not be large enough to hold the ipv6 address.

Files:
2 modified

Legend:

Unmodified
Added
Removed
  • m4/gssapi.m4

    r3046 r3545  
    77dnl Defines GSSAPI_CFLAGS and GSSAPI_LIBS if found. 
    88dnl Defines GSSAPI_IMPL to "Heimdal", "MIT", or "OldMIT", or "none" if not found 
    9 AC_DEFUN(MUTT_AM_PATH_GSSAPI, 
     9AC_DEFUN([MUTT_AM_PATH_GSSAPI], 
    1010[ 
    1111  GSSAPI_PREFIX=[$]$1 
  • mutt_sasl.c

    r3475 r3545  
    3333#include <netinet/in.h> 
    3434 
     35#ifdef USE_SASL2 
     36static int getnameinfo_err(int ret) 
     37{ 
     38  int err; 
     39  dprint (1, (debugfile, "getnameinfo: ")); 
     40  switch(ret) 
     41  { 
     42     case EAI_AGAIN: 
     43       dprint (1, (debugfile, "The name could not be resolved at this time.  Future attempts may succeed.\n")); 
     44       err=SASL_TRYAGAIN; 
     45       break; 
     46     case EAI_BADFLAGS: 
     47       dprint (1, (debugfile, "The flags had an invalid value.\n")); 
     48       err=SASL_BADPARAM; 
     49       break; 
     50     case EAI_FAIL: 
     51       dprint (1, (debugfile, "A non-recoverable error occurred.\n")); 
     52       err=SASL_FAIL; 
     53       break; 
     54     case EAI_FAMILY: 
     55       dprint (1, (debugfile, "The address family was not recognized or the address length was invalid for the specified family.\n")); 
     56       err=SASL_BADPROT; 
     57       break; 
     58     case EAI_MEMORY: 
     59       dprint (1, (debugfile, "There was a memory allocation failure.\n")); 
     60       err=SASL_NOMEM; 
     61       break; 
     62     case EAI_NONAME: 
     63       dprint (1, (debugfile, "The name does not resolve for the supplied parameters.  NI_NAMEREQD is set and the host's name cannot be located, or both nodename and servname were null.\n")); 
     64       err=SASL_FAIL; /* no real equivalent */ 
     65       break; 
     66     case EAI_SYSTEM: 
     67       dprint (1, (debugfile, "A system error occurred.  The error code can be found in errno(%d,%s)).\n",errno,strerror(errno))); 
     68       err=SASL_FAIL; /* no real equivalent */ 
     69       break; 
     70     default: 
     71       dprint (1, (debugfile, "Unknown error %d\n",ret)); 
     72       err=SASL_FAIL; /* no real equivalent */ 
     73       break; 
     74  } 
     75  return err; 
     76} 
     77#endif 
     78 
    3579/* arbitrary. SASL will probably use a smaller buffer anyway. OTOH it's 
    3680 * been a while since I've had access to an SASL server which negotiated 
     
    65109                     char *out, unsigned outlen) { 
    66110    char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV]; 
     111    int ret; 
    67112     
    68113    if(!addr || !out) return SASL_BADPARAM; 
    69114 
    70     getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), 
    71                 NI_NUMERICHOST | 
     115    ret=getnameinfo(addr, addrlen, hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), 
     116                   NI_NUMERICHOST | 
    72117#ifdef NI_WITHSCOPEID 
    73                 NI_WITHSCOPEID | 
    74 #endif 
    75                 NI_NUMERICSERV); 
     118                   NI_WITHSCOPEID | 
     119#endif 
     120                   NI_NUMERICSERV); 
     121    if(ret) 
     122      return getnameinfo_err(ret); 
    76123 
    77124    if(outlen < strlen(hbuf) + strlen(pbuf) + 2) 
     
    125172  sasl_security_properties_t secprops; 
    126173#ifdef USE_SASL2 
    127   struct sockaddr local, remote; 
     174  struct sockaddr_storage local, remote; 
    128175  socklen_t size; 
    129176  char iplocalport[IP_PORT_BUFLEN], ipremoteport[IP_PORT_BUFLEN]; 
     
    152199#ifdef USE_SASL2 
    153200  size = sizeof (local); 
    154   if (getsockname (conn->fd, &local, &size)){ 
     201  if (getsockname (conn->fd, (struct sockaddr *)&local, &size)){ 
    155202    dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for local failed\n")); 
    156203    return -1; 
    157204  } 
    158205  else  
    159   if (iptostring(&local, size, iplocalport, IP_PORT_BUFLEN) != SASL_OK){ 
     206  if (iptostring((struct sockaddr *)&local, local.ss_len, iplocalport, IP_PORT_BUFLEN) != SASL_OK){ 
    160207    dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for local failed\n")); 
    161208    return -1; 
     
    163210   
    164211  size = sizeof (remote); 
    165   if (getpeername (conn->fd, &remote, &size)){ 
     212  if (getpeername (conn->fd, (struct sockaddr *)&remote, &size)){ 
    166213    dprint (1, (debugfile, "mutt_sasl_client_new: getsockname for remote failed\n")); 
    167214    return -1; 
    168215  } 
    169216  else  
    170   if (iptostring(&remote, size, ipremoteport, IP_PORT_BUFLEN) != SASL_OK){ 
     217  if (iptostring((struct sockaddr *)&remote, remote.ss_len, ipremoteport, IP_PORT_BUFLEN) != SASL_OK){ 
    171218    dprint (1, (debugfile, "mutt_sasl_client_new: iptostring for remote failed\n")); 
    172219    return -1;