|
Lines 87-93
Link Here
|
| 87 |
/* RIPE flags */ |
87 |
/* RIPE flags */ |
| 88 |
if (strchr(ripeflags, ch)) { |
88 |
if (strchr(ripeflags, ch)) { |
| 89 |
for (p = fstring; *p; p++); |
89 |
for (p = fstring; *p; p++); |
| 90 |
sprintf(p--, "-%c ", ch); |
90 |
snprintf(p--, sizeof(fstring), "-%c ", ch); |
| 91 |
continue; |
91 |
continue; |
| 92 |
} |
92 |
} |
| 93 |
if (strchr(ripeflagsp, ch)) { |
93 |
if (strchr(ripeflagsp, ch)) { |
|
Lines 132-138
Link Here
|
| 132 |
usage(); |
132 |
usage(); |
| 133 |
|
133 |
|
| 134 |
/* On some systems realloc only works on non-NULL buffers */ |
134 |
/* On some systems realloc only works on non-NULL buffers */ |
| 135 |
qstring = malloc(64); |
135 |
qstring = xmalloc(64); |
| 136 |
*qstring = '\0'; |
136 |
*qstring = '\0'; |
| 137 |
|
137 |
|
| 138 |
/* parse other parameters, if any */ |
138 |
/* parse other parameters, if any */ |
|
Lines 141-151
Link Here
|
| 141 |
|
141 |
|
| 142 |
while (1) { |
142 |
while (1) { |
| 143 |
qslen += strlen(*argv) + 1 + 1; |
143 |
qslen += strlen(*argv) + 1 + 1; |
| 144 |
qstring = realloc(qstring, qslen); |
144 |
qstring = xrealloc(qstring, qslen); |
| 145 |
strcat(qstring, *argv++); |
145 |
strncat(qstring, *argv++, qslen-1); |
| 146 |
if (argc == 1) |
146 |
if (argc == 1) |
| 147 |
break; |
147 |
break; |
| 148 |
strcat(qstring, " "); |
148 |
strncat(qstring, " ", qslen-1); |
| 149 |
argc--; |
149 |
argc--; |
| 150 |
} |
150 |
} |
| 151 |
} |
151 |
} |
|
Lines 467-474
Link Here
|
| 467 |
char *buf, *p; |
467 |
char *buf, *p; |
| 468 |
int i, isripe = 0; |
468 |
int i, isripe = 0; |
| 469 |
|
469 |
|
|
|
470 |
/* buflen was always 0 in original patch and buf was allocated twice /Aye */ |
| 470 |
/* 64 bytes reserved for server-specific flags added later */ |
471 |
/* 64 bytes reserved for server-specific flags added later */ |
| 471 |
buf = malloc(strlen(flags) + strlen(query) + strlen(client_tag) + 64); |
472 |
int buflen = strlen(flags) + strlen(query) + strlen(client_tag) + 64; |
|
|
473 |
buf = xmalloc(buflen); |
| 472 |
*buf = '\0'; |
474 |
*buf = '\0'; |
| 473 |
for (i = 0; ripe_servers[i]; i++) |
475 |
for (i = 0; ripe_servers[i]; i++) |
| 474 |
if (streq(server, ripe_servers[i])) { |
476 |
if (streq(server, ripe_servers[i])) { |
|
Lines 481-487
Link Here
|
| 481 |
if (*flags) { |
483 |
if (*flags) { |
| 482 |
if (!isripe && !streq(server, "whois.corenic.net")) |
484 |
if (!isripe && !streq(server, "whois.corenic.net")) |
| 483 |
puts(_("Warning: RIPE flags used with a traditional server.")); |
485 |
puts(_("Warning: RIPE flags used with a traditional server.")); |
| 484 |
strcat(buf, flags); |
486 |
strncat(buf, flags, buflen-1); |
| 485 |
} |
487 |
} |
| 486 |
|
488 |
|
| 487 |
#ifdef HAVE_LIBIDN |
489 |
#ifdef HAVE_LIBIDN |
|
Lines 490-517
Link Here
|
| 490 |
*/ |
492 |
*/ |
| 491 |
if (streq(server, "whois.denic.de") && domcmp(query, ".de") |
493 |
if (streq(server, "whois.denic.de") && domcmp(query, ".de") |
| 492 |
&& !strchr(query, ' ') && !*flags) |
494 |
&& !strchr(query, ' ') && !*flags) |
| 493 |
sprintf(buf, "-T dn,ace -C US-ASCII %s", query); |
495 |
snprintf(buf, buflen-1, "-T dn,ace -C US-ASCII %s", query); |
| 494 |
else |
496 |
else |
| 495 |
/* here we have another registrar who could not make things simple |
497 |
/* here we have another registrar who could not make things simple |
| 496 |
* -C sets the language for both input and output |
498 |
* -C sets the language for both input and output |
| 497 |
*/ |
499 |
*/ |
| 498 |
if (!isripe && streq(server, "whois.cat") && domcmp(query, ".cat") |
500 |
if (!isripe && streq(server, "whois.cat") && domcmp(query, ".cat") |
| 499 |
&& !strchr(query, ' ')) |
501 |
&& !strchr(query, ' ')) |
| 500 |
sprintf(buf, "-C US-ASCII ace %s", query); |
502 |
snprintf(buf, buflen-1, "-C US-ASCII ace %s", query); |
| 501 |
else |
503 |
else |
| 502 |
#endif |
504 |
#endif |
| 503 |
if (!isripe && (streq(server, "whois.nic.mil") || |
505 |
if (!isripe && (streq(server, "whois.nic.mil") || |
| 504 |
streq(server, "whois.nic.ad.jp")) && |
506 |
streq(server, "whois.nic.ad.jp")) && |
| 505 |
strncaseeq(query, "AS", 2) && isasciidigit(query[2])) |
507 |
strncaseeq(query, "AS", 2) && isasciidigit(query[2])) |
| 506 |
/* FIXME: /e is not applied to .JP ASN */ |
508 |
/* FIXME: /e is not applied to .JP ASN */ |
| 507 |
sprintf(buf, "AS %s", query + 2); /* fix query for DDN */ |
509 |
snprintf(buf, buflen-1, "AS %s", query + 2); /* fix query for DDN */ |
| 508 |
else if (!isripe && (streq(server, "whois.nic.ad.jp") || |
510 |
else if (!isripe && (streq(server, "whois.nic.ad.jp") || |
| 509 |
streq(server, "whois.jprs.jp"))) { |
511 |
streq(server, "whois.jprs.jp"))) { |
| 510 |
char *lang = getenv("LANG"); /* not a perfect check, but... */ |
512 |
char *lang = getenv("LANG"); /* not a perfect check, but... */ |
| 511 |
if (!lang || !strneq(lang, "ja", 2)) |
513 |
if (!lang || !strneq(lang, "ja", 2)) |
| 512 |
sprintf(buf, "%s/e", query); /* ask for english text */ |
514 |
snprintf(buf, buflen-1, "%s/e", query); /* ask for english text */ |
| 513 |
else |
515 |
else |
| 514 |
strcat(buf, query); |
516 |
strncat(buf, query, buflen-1); |
| 515 |
} else if (!isripe && streq(server, "whois.arin.net") && |
517 |
} else if (!isripe && streq(server, "whois.arin.net") && |
| 516 |
(p = strrchr(query, '/'))) { |
518 |
(p = strrchr(query, '/'))) { |
| 517 |
strncat(buf, query, p - query); /* strip CIDR */ |
519 |
strncat(buf, query, p - query); /* strip CIDR */ |
|
Lines 582-588
Link Here
|
| 582 |
|
584 |
|
| 583 |
if (sscanf(buf, REFERTO_FORMAT, nh, np, nq) == 3) { |
585 |
if (sscanf(buf, REFERTO_FORMAT, nh, np, nq) == 3) { |
| 584 |
/* XXX we are ignoring the new query string */ |
586 |
/* XXX we are ignoring the new query string */ |
| 585 |
referral_server = malloc(300); |
587 |
referral_server = xmalloc(300); |
| 586 |
sprintf(referral_server, "%s:%s", nh, np); |
588 |
sprintf(referral_server, "%s:%s", nh, np); |
| 587 |
} |
589 |
} |
| 588 |
} |
590 |
} |
|
Lines 631-637
Link Here
|
| 631 |
int hide = hide_discl; |
633 |
int hide = hide_discl; |
| 632 |
int state = 0; |
634 |
int state = 0; |
| 633 |
|
635 |
|
| 634 |
temp = malloc(strlen(query) + 1 + 2 + 1); |
636 |
temp = xmalloc(strlen(query) + 1 + 2 + 1); |
| 635 |
*temp = '='; |
637 |
*temp = '='; |
| 636 |
strcpy(temp + 1, query); |
638 |
strcpy(temp + 1, query); |
| 637 |
strcat(temp, "\r\n"); |
639 |
strcat(temp, "\r\n"); |
|
Lines 649-655
Link Here
|
| 649 |
|
651 |
|
| 650 |
for (p = buf; *p != ':'; p++); /* skip until colon */ |
652 |
for (p = buf; *p != ':'; p++); /* skip until colon */ |
| 651 |
for (p++; *p == ' '; p++); /* skip colon and spaces */ |
653 |
for (p++; *p == ' '; p++); /* skip colon and spaces */ |
| 652 |
ret = malloc(strlen(p) + 1); |
654 |
ret = xmalloc(strlen(p) + 1); |
| 653 |
for (q = ret; *p != '\n' && *p != '\r' && *p != ' '; *q++ = *p++) |
655 |
for (q = ret; *p != '\n' && *p != '\r' && *p != ' '; *q++ = *p++) |
| 654 |
; /*copy data*/ |
656 |
; /*copy data*/ |
| 655 |
*q = '\0'; |
657 |
*q = '\0'; |
|
Lines 674-680
Link Here
|
| 674 |
int hide = hide_discl; |
676 |
int hide = hide_discl; |
| 675 |
int state = 0; |
677 |
int state = 0; |
| 676 |
|
678 |
|
| 677 |
temp = malloc(strlen(query) + 5 + 2 + 1); |
679 |
temp = xmalloc(strlen(query) + 5 + 2 + 1); |
| 678 |
strcpy(temp, "FULL "); |
680 |
strcpy(temp, "FULL "); |
| 679 |
strcat(temp, query); |
681 |
strcat(temp, query); |
| 680 |
strcat(temp, "\r\n"); |
682 |
strcat(temp, "\r\n"); |
|
Lines 695-701
Link Here
|
| 695 |
for (p = buf; *p != ':'; p++); /* skip until colon */ |
697 |
for (p = buf; *p != ':'; p++); /* skip until colon */ |
| 696 |
for (p++; *p != ':'; p++); /* skip until 2nd colon */ |
698 |
for (p++; *p != ':'; p++); /* skip until 2nd colon */ |
| 697 |
for (p++; *p == ' '; p++); /* skip colon and spaces */ |
699 |
for (p++; *p == ' '; p++); /* skip colon and spaces */ |
| 698 |
ret = malloc(strlen(p) + 1); |
700 |
ret = xmalloc(strlen(p) + 1); |
| 699 |
for (q = ret; *p != '\n' && *p != '\r'; *q++ = *p++); /*copy data*/ |
701 |
for (q = ret; *p != '\n' && *p != '\r'; *q++ = *p++); /*copy data*/ |
| 700 |
*q = '\0'; |
702 |
*q = '\0'; |
| 701 |
state = 2; |
703 |
state = 2; |
|
Lines 733-739
Link Here
|
| 733 |
|
735 |
|
| 734 |
for (p = buf; *p != ':'; p++); /* skip until colon */ |
736 |
for (p = buf; *p != ':'; p++); /* skip until colon */ |
| 735 |
for (p++; *p == ' '; p++); /* skip colon and spaces */ |
737 |
for (p++; *p == ' '; p++); /* skip colon and spaces */ |
| 736 |
ret = malloc(strlen(p) + 1); |
738 |
ret = xmalloc(strlen(p) + 1); |
| 737 |
for (q = ret; *p != '\n' && *p != '\r' && *p != ' '; *q++ = *p++) |
739 |
for (q = ret; *p != '\n' && *p != '\r' && *p != ' '; *q++ = *p++) |
| 738 |
; /*copy data*/ |
740 |
; /*copy data*/ |
| 739 |
*q = '\0'; |
741 |
*q = '\0'; |
|
Lines 936-942
Link Here
|
| 936 |
|
938 |
|
| 937 |
char *convert_6to4(const char *s) |
939 |
char *convert_6to4(const char *s) |
| 938 |
{ |
940 |
{ |
| 939 |
char *new = malloc(sizeof("255.255.255.255")); |
941 |
char *new = xmalloc(sizeof("255.255.255.255")); |
| 940 |
unsigned int a, b; |
942 |
unsigned int a, b; |
| 941 |
|
943 |
|
| 942 |
if (sscanf(s, "2002:%x:%x:", &a, &b) != 2) |
944 |
if (sscanf(s, "2002:%x:%x:", &a, &b) != 2) |
|
Lines 948-954
Link Here
|
| 948 |
|
950 |
|
| 949 |
char *convert_teredo(const char *s) |
951 |
char *convert_teredo(const char *s) |
| 950 |
{ |
952 |
{ |
| 951 |
char *new = malloc(sizeof("255.255.255.255")); |
953 |
char *new = xmalloc(sizeof("255.255.255.255")); |
| 952 |
unsigned int a, b; |
954 |
unsigned int a, b; |
| 953 |
|
955 |
|
| 954 |
if (sscanf(s, "2001:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%x:%x", &a, &b) != 2) |
956 |
if (sscanf(s, "2001:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%*[^:]:%x:%x", &a, &b) != 2) |
|
Lines 1030-1032
Link Here
|
| 1030 |
exit(0); |
1032 |
exit(0); |
| 1031 |
} |
1033 |
} |
| 1032 |
|
1034 |
|
| 1033 |
-- whois.h.orig 2008-04-29 11:27:20.000000000 +0200 |
1035 |
/* Memory allocation routines */ |
|
|
1036 |
void *xmalloc(size_t size) |
| 1037 |
{ |
| 1038 |
void *ptr; |
| 1039 |
if ((ptr = malloc(size)) == NULL) |
| 1040 |
err_sys("malloc"); |
| 1041 |
return ptr; |
| 1042 |
} |
| 1043 |
|
| 1044 |
void *xrealloc(void *ptr, size_t size) |
| 1045 |
{ |
| 1046 |
if ((ptr = realloc(ptr, size)) == NULL) |
| 1047 |
err_sys("realloc"); |
| 1048 |
return ptr; |
| 1049 |
} |
|
|
1050 |
++ whois.h 2008-04-29 11:28:32.000000000 +0200 |
|
Lines 36-41
Link Here
|
| 36 |
void split_server_port(const char *const input, const char **server, |
36 |
void split_server_port(const char *const input, const char **server, |
| 37 |
const char **port); |
37 |
const char **port); |
|
|
38 |
void *xmalloc(size_t); |
| 39 |
void *xrealloc(void *, size_t); |
| 38 |
/* flags for RIPE-like servers */ |
40 |
/* flags for RIPE-like servers */ |
| 39 |
const char *ripeflags="abBcdFGKlLmMrRSx"; |
41 |
const char *ripeflags="abBcdFGKlLmMrRSx"; |