Created
February 15, 2010 17:47
-
-
Save msantos/304825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Excessively long hostname lookup on Mac OS X Snow Leopard | |
* | |
* gcc -g -Wall -o gho gho.c | |
* ./gho 69982 | |
* | |
* Feb 15 12:42:47 ack mDNSResponder[18]: 77: ERROR: read_msg - hdr.datalen 70001 (11171) > 70000 | |
* Feb 15 12:42:47 ack ./gho[4852]: dnssd_clientstub write_all(4) failed -1/70028 32 Broken pipe | |
* Feb 15 12:42:47 ack ./gho[4852]: dnssd_clientstub deliver_request ERROR: write_all(4, 70028 bytes) failed | |
* Feb 15 12:42:47 ack ./gho[4852]: dnssd_clientstub write_all(4) failed -1/28 32 Broken pipe | |
* | |
*/ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <netdb.h> | |
#include <err.h> | |
#include <string.h> | |
int | |
main (int argc, char *argv[]) | |
{ | |
char *host = NULL; | |
size_t len = 0; | |
struct hostent *he = NULL; | |
if (argc != 2) | |
errx(EXIT_FAILURE, "%s: <length>", argv[0]); | |
len = (size_t)atoi(argv[1]) + 1; | |
host = calloc(len, 1); | |
if (host == NULL) | |
err(EXIT_FAILURE, "calloc"); | |
(void)memset(host, 'x', len-1); | |
(void)printf("Length = %lu\n", strlen(host)); | |
he = gethostbyname(host); | |
if (he == NULL) | |
errx(EXIT_FAILURE, "Error resolving: %s", host); | |
(void)printf("Official hostname = %s\n", he->h_name); | |
exit(0); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment