- (djm) Don't use xmalloc() or pull in toplevel headers in fake-* code
This commit is contained in:
parent
ceb3136f5f
commit
b95bb7f9b1
|
@ -4,6 +4,7 @@
|
||||||
- (djm) Implement paranoid priv dropping checks, based on:
|
- (djm) Implement paranoid priv dropping checks, based on:
|
||||||
"SetUID demystified" - Hao Chen, David Wagner and Drew Dean
|
"SetUID demystified" - Hao Chen, David Wagner and Drew Dean
|
||||||
Proceedings of USENIX Security Symposium 2002
|
Proceedings of USENIX Security Symposium 2002
|
||||||
|
- (djm) Don't use xmalloc() or pull in toplevel headers in fake-* code
|
||||||
|
|
||||||
20030604
|
20030604
|
||||||
- (djm) Bug #573 - Remove unneeded Krb headers and compat goop. Patch from
|
- (djm) Bug #573 - Remove unneeded Krb headers and compat goop. Patch from
|
||||||
|
@ -465,4 +466,4 @@
|
||||||
- Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
|
- Fix sshd BindAddress and -b options for systems using fake-getaddrinfo.
|
||||||
Report from murple@murple.net, diagnosis from dtucker@zip.com.au
|
Report from murple@murple.net, diagnosis from dtucker@zip.com.au
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.2783 2003/06/04 23:53:42 djm Exp $
|
$Id: ChangeLog,v 1.2784 2003/06/05 00:04:12 djm Exp $
|
||||||
|
|
|
@ -10,10 +10,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "xmalloc.h"
|
|
||||||
#include "ssh.h"
|
|
||||||
|
|
||||||
RCSID("$Id: fake-getaddrinfo.c,v 1.9 2003/06/04 23:48:33 djm Exp $");
|
RCSID("$Id: fake-getaddrinfo.c,v 1.10 2003/06/05 00:04:12 djm Exp $");
|
||||||
|
|
||||||
#ifndef HAVE_GAI_STRERROR
|
#ifndef HAVE_GAI_STRERROR
|
||||||
char *
|
char *
|
||||||
|
@ -52,7 +50,9 @@ addrinfo *malloc_ai(int port, u_long addr, const struct addrinfo *hints)
|
||||||
{
|
{
|
||||||
struct addrinfo *ai;
|
struct addrinfo *ai;
|
||||||
|
|
||||||
ai = xmalloc(sizeof(*ai) + sizeof(struct sockaddr_in));
|
ai = malloc(sizeof(*ai) + sizeof(struct sockaddr_in));
|
||||||
|
if (ai == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in));
|
memset(ai, '\0', sizeof(*ai) + sizeof(struct sockaddr_in));
|
||||||
|
|
||||||
|
@ -105,16 +105,22 @@ getaddrinfo(const char *hostname, const char *servname,
|
||||||
if (hostname && inet_aton(hostname, &in) != 0)
|
if (hostname && inet_aton(hostname, &in) != 0)
|
||||||
addr = in.s_addr;
|
addr = in.s_addr;
|
||||||
*res = malloc_ai(port, addr, hints);
|
*res = malloc_ai(port, addr, hints);
|
||||||
|
if (*res == NULL)
|
||||||
|
return (EAI_MEMORY);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hostname) {
|
if (!hostname) {
|
||||||
*res = malloc_ai(port, htonl(0x7f000001), hints);
|
*res = malloc_ai(port, htonl(0x7f000001), hints);
|
||||||
|
if (*res == NULL)
|
||||||
|
return (EAI_MEMORY);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inet_aton(hostname, &in)) {
|
if (inet_aton(hostname, &in)) {
|
||||||
*res = malloc_ai(port, in.s_addr, hints);
|
*res = malloc_ai(port, in.s_addr, hints);
|
||||||
|
if (*res == NULL)
|
||||||
|
return (EAI_MEMORY);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +132,16 @@ getaddrinfo(const char *hostname, const char *servname,
|
||||||
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
|
if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) {
|
||||||
struct addrinfo *cur, *prev;
|
struct addrinfo *cur, *prev;
|
||||||
|
|
||||||
cur = prev = NULL;
|
cur = prev = *res = NULL;
|
||||||
for (i = 0; hp->h_addr_list[i]; i++) {
|
for (i = 0; hp->h_addr_list[i]; i++) {
|
||||||
struct in_addr *in = (struct in_addr *)hp->h_addr_list[i];
|
struct in_addr *in = (struct in_addr *)hp->h_addr_list[i];
|
||||||
|
|
||||||
cur = malloc_ai(port, in->s_addr, hints);
|
cur = malloc_ai(port, in->s_addr, hints);
|
||||||
|
if (cur == NULL) {
|
||||||
|
if (*res != NULL)
|
||||||
|
freeaddrinfo(*res);
|
||||||
|
return (EAI_MEMORY);
|
||||||
|
}
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->ai_next = cur;
|
prev->ai_next = cur;
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: fake-getaddrinfo.h,v 1.5 2003/06/04 23:48:33 djm Exp $ */
|
/* $Id: fake-getaddrinfo.h,v 1.6 2003/06/05 00:04:12 djm Exp $ */
|
||||||
|
|
||||||
#ifndef _FAKE_GETADDRINFO_H
|
#ifndef _FAKE_GETADDRINFO_H
|
||||||
#define _FAKE_GETADDRINFO_H
|
#define _FAKE_GETADDRINFO_H
|
||||||
|
@ -27,16 +27,16 @@ struct addrinfo {
|
||||||
#endif /* !HAVE_STRUCT_ADDRINFO */
|
#endif /* !HAVE_STRUCT_ADDRINFO */
|
||||||
|
|
||||||
#ifndef HAVE_GETADDRINFO
|
#ifndef HAVE_GETADDRINFO
|
||||||
int getaddrinfo(const char *hostname, const char *servname,
|
int getaddrinfo(const char *, const char *,
|
||||||
const struct addrinfo *hints, struct addrinfo **res);
|
const struct addrinfo *, struct addrinfo **);
|
||||||
#endif /* !HAVE_GETADDRINFO */
|
#endif /* !HAVE_GETADDRINFO */
|
||||||
|
|
||||||
#ifndef HAVE_GAI_STRERROR
|
#ifndef HAVE_GAI_STRERROR
|
||||||
char *gai_strerror(int ecode);
|
char *gai_strerror(int);
|
||||||
#endif /* !HAVE_GAI_STRERROR */
|
#endif /* !HAVE_GAI_STRERROR */
|
||||||
|
|
||||||
#ifndef HAVE_FREEADDRINFO
|
#ifndef HAVE_FREEADDRINFO
|
||||||
void freeaddrinfo(struct addrinfo *ai);
|
void freeaddrinfo(struct addrinfo *);
|
||||||
#endif /* !HAVE_FREEADDRINFO */
|
#endif /* !HAVE_FREEADDRINFO */
|
||||||
|
|
||||||
#endif /* _FAKE_GETADDRINFO_H */
|
#endif /* _FAKE_GETADDRINFO_H */
|
||||||
|
|
Loading…
Reference in New Issue