/*
- * locate the originating host
* $Id$
+ *
+ * locate the originating host
+ *
*/
+#ifdef DLL_EXPORT
+#define IN_LIBCIT
+#endif
+
#include "sysdep.h"
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <netdb.h>
#include <string.h>
-#ifdef HAVE_PTHREAD_H
-#include <pthread.h>
-#endif
#include "citadel.h"
#include "server.h"
+#include "dynloader.h"
#include "locate_host.h"
+#include "sysdep_decls.h"
#include "config.h"
+#include "tools.h"
void locate_host(char *tbuf, const struct in_addr *addr)
{
- struct hostent *ch, *ch2;
+ struct hostent *ch;
char *i;
int a1, a2, a3, a4;
+ lprintf(9, "locate_host() called\n");
+
#ifdef HAVE_NONREENTRANT_NETDB
begin_critical_section(S_NETDB);
#endif
section */
}
/* check if the forward DNS agrees; if not, they're spoofing */
- if ((ch2 = gethostbyname(ch->h_name)) == NULL)
+ i = strdoop(ch->h_name);
+ ch = gethostbyname(i);
+ phree(i);
+ if (ch == NULL)
goto bad_dns;
/* check address for consistency */
- for (; *ch2->h_addr_list; ch2->h_addr_list++)
- if (!memcmp(*ch2->h_addr_list, addr,
+ for (; *ch->h_addr_list; ch->h_addr_list++)
+ if (!memcmp(*ch->h_addr_list, addr,
sizeof *addr)) {
- strncpy(tbuf, ch->h_name, 24);
+ safestrncpy(tbuf, ch->h_name, 25);
goto end;
}
goto bad_dns; /* they were spoofing. report a numeric IP
end_critical_section(S_NETDB);
#endif
- tbuf[24] = 0;
+ tbuf[25] = 0;
+ lprintf(9, "locate_host() exiting\n");
}