Changeset View
Changeset View
Standalone View
Standalone View
contrib/tcp_wrappers/workarounds.c
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | /* | ||||
* | * | ||||
* Bug reported by ben@piglet.cr.usgs.gov (Rev. Ben A. Mesander). | * Bug reported by ben@piglet.cr.usgs.gov (Rev. Ben A. Mesander). | ||||
*/ | */ | ||||
#ifdef INET_ADDR_BUG | #ifdef INET_ADDR_BUG | ||||
#undef inet_addr | #undef inet_addr | ||||
long fix_inet_addr(string) | long fix_inet_addr(char *string) | ||||
char *string; | |||||
{ | { | ||||
return (inet_addr(string).s_addr); | return (inet_addr(string).s_addr); | ||||
} | } | ||||
#endif /* INET_ADDR_BUG */ | #endif /* INET_ADDR_BUG */ | ||||
/* | /* | ||||
* With some System-V versions, the fgets() library function does not | * With some System-V versions, the fgets() library function does not | ||||
* account for partial reads from e.g. sockets. The result is that fgets() | * account for partial reads from e.g. sockets. The result is that fgets() | ||||
* gives up too soon, causing username lookups to fail. Problem first | * gives up too soon, causing username lookups to fail. Problem first | ||||
* reported for IRIX 4.0.5, by Steve Kotsopoulos <steve@ecf.toronto.edu>. | * reported for IRIX 4.0.5, by Steve Kotsopoulos <steve@ecf.toronto.edu>. | ||||
* The following code works around the problem. It does no harm on "normal" | * The following code works around the problem. It does no harm on "normal" | ||||
* systems. | * systems. | ||||
*/ | */ | ||||
#ifdef BROKEN_FGETS | #ifdef BROKEN_FGETS | ||||
#undef fgets | #undef fgets | ||||
char *fix_fgets(buf, len, fp) | char *fix_fgets(char *buf, int len, FILE *fp) | ||||
char *buf; | |||||
int len; | |||||
FILE *fp; | |||||
{ | { | ||||
char *cp = buf; | char *cp = buf; | ||||
int c; | int c; | ||||
/* | /* | ||||
* Copy until the buffer fills up, until EOF, or until a newline is | * Copy until the buffer fills up, until EOF, or until a newline is | ||||
* found. | * found. | ||||
*/ | */ | ||||
Show All 23 Lines | /* | ||||
* source address structure when doing a non-destructive read. The following | * source address structure when doing a non-destructive read. The following | ||||
* code works around the problem. It does no harm on "normal" systems. | * code works around the problem. It does no harm on "normal" systems. | ||||
*/ | */ | ||||
#ifdef RECVFROM_BUG | #ifdef RECVFROM_BUG | ||||
#undef recvfrom | #undef recvfrom | ||||
int fix_recvfrom(sock, buf, buflen, flags, from, fromlen) | int fix_recvfrom(int sock, char *buf, int buflen, int flags, | ||||
int sock; | struct sockaddr *from, int *fromlen) | ||||
char *buf; | |||||
int buflen; | |||||
int flags; | |||||
struct sockaddr *from; | |||||
int *fromlen; | |||||
{ | { | ||||
int ret; | int ret; | ||||
/* Assume that both ends of a socket belong to the same address family. */ | /* Assume that both ends of a socket belong to the same address family. */ | ||||
if ((ret = recvfrom(sock, buf, buflen, flags, from, fromlen)) >= 0) { | if ((ret = recvfrom(sock, buf, buflen, flags, from, fromlen)) >= 0) { | ||||
if (from->sa_family == 0) { | if (from->sa_family == 0) { | ||||
struct sockaddr my_addr; | struct sockaddr my_addr; | ||||
Show All 17 Lines | /* | ||||
* UDP requests come from address 0.0.0.0. The following code works around | * UDP requests come from address 0.0.0.0. The following code works around | ||||
* the problem. It does no harm on "normal" systems. | * the problem. It does no harm on "normal" systems. | ||||
*/ | */ | ||||
#ifdef GETPEERNAME_BUG | #ifdef GETPEERNAME_BUG | ||||
#undef getpeername | #undef getpeername | ||||
int fix_getpeername(sock, sa, len) | int fix_getpeername(int sock, struct sockaddr *sa, int *len) | ||||
int sock; | |||||
struct sockaddr *sa; | |||||
int *len; | |||||
{ | { | ||||
int ret; | int ret; | ||||
#ifdef INET6 | #ifdef INET6 | ||||
struct sockaddr *sin = sa; | struct sockaddr *sin = sa; | ||||
#else | #else | ||||
struct sockaddr_in *sin = (struct sockaddr_in *) sa; | struct sockaddr_in *sin = (struct sockaddr_in *) sa; | ||||
#endif | #endif | ||||
Show All 19 Lines | |||||
/* | /* | ||||
* According to Karl Vogel (vogelke@c-17igp.wpafb.af.mil) some Pyramid | * According to Karl Vogel (vogelke@c-17igp.wpafb.af.mil) some Pyramid | ||||
* versions have no yp_default_domain() function. We use getdomainname() | * versions have no yp_default_domain() function. We use getdomainname() | ||||
* instead. | * instead. | ||||
*/ | */ | ||||
#ifdef USE_GETDOMAIN | #ifdef USE_GETDOMAIN | ||||
int yp_get_default_domain(ptr) | int yp_get_default_domain(char **ptr) | ||||
char **ptr; | |||||
{ | { | ||||
static char mydomain[MAXHOSTNAMELEN]; | static char mydomain[MAXHOSTNAMELEN]; | ||||
*ptr = mydomain; | *ptr = mydomain; | ||||
return (getdomainname(mydomain, MAXHOSTNAMELEN)); | return (getdomainname(mydomain, MAXHOSTNAMELEN)); | ||||
} | } | ||||
#endif /* USE_GETDOMAIN */ | #endif /* USE_GETDOMAIN */ | ||||
Show All 11 Lines | /* | ||||
* accidentally left in. A side effect of the workaround is that address | * accidentally left in. A side effect of the workaround is that address | ||||
* list members are no longer properly aligned for structure access. | * list members are no longer properly aligned for structure access. | ||||
*/ | */ | ||||
#ifdef SOLARIS_24_GETHOSTBYNAME_BUG | #ifdef SOLARIS_24_GETHOSTBYNAME_BUG | ||||
#undef gethostbyname | #undef gethostbyname | ||||
struct hostent *fix_gethostbyname(name) | struct hostent *fix_gethostbyname(char *name) | ||||
char *name; | |||||
{ | { | ||||
struct hostent *hp; | struct hostent *hp; | ||||
struct in_addr addr; | struct in_addr addr; | ||||
char **o_addr_list; | char **o_addr_list; | ||||
char **o_aliases; | char **o_aliases; | ||||
char **n_addr_list; | char **n_addr_list; | ||||
int broken_gethostbyname = 0; | int broken_gethostbyname = 0; | ||||
Show All 20 Lines | |||||
/* | /* | ||||
* Horror! Some FreeBSD 2.0 libc routines call strtok(). Since tcpd depends | * Horror! Some FreeBSD 2.0 libc routines call strtok(). Since tcpd depends | ||||
* heavily on strtok(), strange things may happen. Workaround: use our | * heavily on strtok(), strange things may happen. Workaround: use our | ||||
* private strtok(). This has been fixed in the meantime. | * private strtok(). This has been fixed in the meantime. | ||||
*/ | */ | ||||
#ifdef USE_STRSEP | #ifdef USE_STRSEP | ||||
char *fix_strtok(buf, sep) | char *fix_strtok(char *buf, char *sep) | ||||
char *buf; | |||||
char *sep; | |||||
{ | { | ||||
static char *state; | static char *state; | ||||
char *result; | char *result; | ||||
if (buf) | if (buf) | ||||
state = buf; | state = buf; | ||||
while ((result = strsep(&state, sep)) && result[0] == 0) | while ((result = strsep(&state, sep)) && result[0] == 0) | ||||
/* void */ ; | /* void */ ; | ||||
return (result); | return (result); | ||||
} | } | ||||
#endif /* USE_STRSEP */ | #endif /* USE_STRSEP */ | ||||
/* | /* | ||||
* IRIX 5.3 (and possibly earlier versions, too) library routines call the | * IRIX 5.3 (and possibly earlier versions, too) library routines call the | ||||
* non-reentrant strtok() library routine, causing hosts to slip through | * non-reentrant strtok() library routine, causing hosts to slip through | ||||
* allow/deny filters. Workaround: don't rely on the vendor and use our own | * allow/deny filters. Workaround: don't rely on the vendor and use our own | ||||
* strtok() function. FreeBSD 2.0 has a similar problem (fixed in 2.0.5). | * strtok() function. FreeBSD 2.0 has a similar problem (fixed in 2.0.5). | ||||
*/ | */ | ||||
#ifdef LIBC_CALLS_STRTOK | #ifdef LIBC_CALLS_STRTOK | ||||
char *my_strtok(buf, sep) | char *my_strtok(char *buf, char *sep) | ||||
char *buf; | |||||
char *sep; | |||||
{ | { | ||||
static char *state; | static char *state; | ||||
char *result; | char *result; | ||||
if (buf) | if (buf) | ||||
state = buf; | state = buf; | ||||
/* | /* | ||||
Show All 15 Lines |