sasl.c revision d0fccfcda73f8b52d101bd2b0f7885a766f7e354
/*
* Copyright (c) 2001-2002 Sendmail, Inc. and its suppliers.
* All rights reserved.
*
* By using this file, you agree to the terms and conditions set
* forth in the LICENSE file which can be found at the top level of
* the sendmail distribution.
*
*/
#if SASL
# include <stdlib.h>
# include <sendmail.h>
# include <errno.h>
/*
** In order to ensure that storage leaks are tracked, and to prevent
** conflicts between the sm_heap package and sasl, we tell sasl to
** use the following heap allocation functions. Unfortunately,
** the sasl package incorrectly specifies the size of a block
** using unsigned long: for portability, it should be size_t.
*/
void *sm_sasl_malloc __P((unsigned long));
static void *sm_sasl_calloc __P((unsigned long, unsigned long));
static void *sm_sasl_realloc __P((void *, unsigned long));
void sm_sasl_free __P((void *));
/*
** SASLv1:
** We can't use an rpool for Cyrus-SASL memory management routines,
** since the encryption/decryption routines in Cyrus-SASL
** allocate/deallocate a buffer each time. Since rpool
** don't release memory until the very end, memory consumption is
** proportional to the size of an e-mail, which is unacceptable.
*/
/*
** SM_SASL_MALLOC -- malloc() for SASL
**
** Parameters:
** size -- size of requested memory.
**
** Returns:
** pointer to memory.
*/
void *
unsigned long size;
{
}
/*
** SM_SASL_CALLOC -- calloc() for SASL
**
** Parameters:
** nelem -- number of elements.
** elemsize -- size of each element.
**
** Returns:
** pointer to memory.
**
** Notice:
** this isn't currently used by SASL.
*/
static void *
unsigned long nelem;
unsigned long elemsize;
{
void *p;
if (p == NULL)
return NULL;
return p;
}
/*
** SM_SASL_REALLOC -- realloc() for SASL
**
** Parameters:
** p -- pointer to old memory.
** size -- size of requested memory.
**
** Returns:
** pointer to new memory.
*/
static void *
sm_sasl_realloc(o, size)
void *o;
unsigned long size;
{
}
/*
** SM_SASL_FREE -- free() for SASL
**
** Parameters:
** p -- pointer to free.
**
** Returns:
** none
*/
void
sm_sasl_free(p)
void *p;
{
sm_free(p);
}
/*
** SM_SASL_INIT -- sendmail specific SASL initialization
**
** Parameters:
** none.
**
** Returns:
** none
**
** Side Effects:
** installs memory management routines for SASL.
*/
void
{
}
/*
** INTERSECT -- create the intersection between two lists
**
** Parameters:
** s1, s2 -- lists of items (separated by single blanks).
** rpool -- resource pool from which result is allocated.
**
** Returns:
** the intersection of both lists.
*/
char *
{
return NULL;
return NULL;
*res = '\0';
if (rl == 0) /* at least one string empty? */
return res;
h = s1;
/* walk through s1 */
{
/* is there something after the current word? */
*h = '\0';
/* does the current word appear in s2 ? */
{
/* add a blank if not first item */
*hr++ = ' ';
/* copy the item */
/* advance pointer in result list */
*hr = '\0';
}
if (h != NULL)
{
/* there are more items */
*h = ' ';
h1 = h + 1;
}
}
return res;
}
# if SASL >= 20000
/*
** IPTOSTRING -- create string for SASL_IP*PORT property
** (borrowed from lib/iptostring.c in Cyrus-IMAP)
**
** Parameters:
** addr -- (pointer to) socket address
** addrlen -- length of socket address
** out -- output string (result)
** outlen -- maximum length of output string
**
** Returns:
** true iff successful.
**
** Side Effects:
** creates output string if successful.
** sets errno if unsuccessful.
*/
# ifndef NI_MAXHOST
# define NI_MAXHOST 1025
# endif
# ifndef NI_MAXSERV
# define NI_MAXSERV 32
# endif
bool
char *out;
unsigned outlen;
{
# if NETINET6
int niflags;
# endif /* NETINET6 */
{
return false;
}
# if NETINET6
# ifdef NI_WITHSCOPEID
# endif /* NI_WITHSCOPEID */
return false;
# else /* NETINET6 */
{
return false;
}
>= sizeof(hbuf))
{
return false;
}
# endif /* NETINET6 */
{
return false;
}
return true;
}
# endif /* SASL >= 20000 */
#endif /* SASL */