From 523c545e45fbdca55c0c070f4e0f252df6b5342b Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Thu, 7 Aug 2014 04:38:39 +0200 Subject: [PATCH 01/14] Update the .my TLD server Same server, new official name. --- tld_serv_list | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tld_serv_list b/tld_serv_list index 15a583f..51fa1c6 100644 --- a/tld_serv_list +++ b/tld_serv_list @@ -226,7 +226,7 @@ .mv NONE # NIC? www.dhiraagu.com.mv .mw WEB http://www.registrar.mw/ .mx whois.mx -.my whois.domainregistry.my +.my whois.mynic.my .mz NONE # NIC? www.uem.mz .na whois.na-nic.com.na .nc whois.nc @@ -373,7 +373,7 @@ .xn--mgbbh1a71e whois.inregistry.net # India, Urdu AW .xn--mgbc0a9azcg NONE # Morocco .xn--mgberp4a5d4ar whois.nic.net.sa # Saudi Arabia -.xn--mgbx4cd0ab whois.domainregistry.my # Malaysia AW +.xn--mgbx4cd0ab whois.mynic.my # Malaysia AW .xn--o3cw4h whois.thnic.co.th # Thailand .xn--ogbpf8fl whois.tld.sy # Syria .xn--p1ai whois.tcinet.ru # Russian Federation From ae2a5775acf55f86d721a8b25370fc3c0addd7da Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Wed, 3 Sep 2014 01:24:25 +0200 Subject: [PATCH 02/14] Add a new ASN allocation --- as_del_list | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/as_del_list b/as_del_list index 78db13e..9b133e4 100644 --- a/as_del_list +++ b/as_del_list @@ -87,7 +87,7 @@ 61952 62463 ripe # catch all: everything else comes from ARIN 1 63487 arin -63488 63999 apnic +63488 64098 apnic # documentation and private ASN block 64496 65534 ripe From f8b28e9ea5251197a89f5692dc68272fe1161f7d Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Wed, 3 Sep 2014 01:25:56 +0200 Subject: [PATCH 03/14] Add new recovered IPv4 allocations --- ip_del_recovered.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ip_del_recovered.h b/ip_del_recovered.h index 1f0707d..d10cd0a 100644 --- a/ip_del_recovered.h +++ b/ip_del_recovered.h @@ -2,11 +2,16 @@ { 736886784UL, 737411071UL, "whois.apnic.net" }, { 737476608UL, 738000895UL, "whois.apnic.net" }, { 738066432UL, 738197503UL, "whois.apnic.net" }, +{ 756023296UL, 757071871UL, "whois.arin.net" }, { 757071872UL, 759169023UL, "whois.arin.net" }, { 759169024UL, 759238655UL, "whois.apnic.net" }, +{ 760217600UL, 761266175UL, "whois.ripe.net" }, +{ 761266176UL, 762314751UL, "whois.afrinic.net" }, +{ 762314752UL, 763363327UL, "whois.apnic.net" }, { 763363328UL, 765460479UL, "whois.ripe.net" }, { 765460480UL, 767557631UL, "whois.lacnic.net" }, { 767557632UL, 769589247UL, "whois.afrinic.net" }, +{ 769654784UL, 770703359UL, "whois.lacnic.net" }, { 2523594752UL, 2523660287UL, "whois.apnic.net" }, { 2525036544UL, 2525102079UL, "whois.apnic.net" }, { 2532442112UL, 2532507647UL, "whois.apnic.net" }, From 9c0fbf514bc1e2870366567d5db6d639069bce74 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 01:02:13 +0200 Subject: [PATCH 04/14] mkpasswd: the number of random bytes is unsigned --- mkpasswd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkpasswd.c b/mkpasswd.c index 785637c..8e56323 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -115,7 +115,7 @@ static const struct crypt_method methods[] = { }; void generate_salt(char *const buf, const unsigned int len); -void *get_random_bytes(const int len); +void *get_random_bytes(const unsigned int len); void display_help(int error); void display_version(void); void display_methods(void); @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) } #ifdef RANDOM_DEVICE -void* get_random_bytes(const int count) +void* get_random_bytes(const unsigned int count) { char *buf; int fd; From 0ba80dd8b3c2d688406cae448ffc109c4e773858 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 02:40:40 +0200 Subject: [PATCH 05/14] mkpasswd: correctly report read(2) failures They would always be reported as a short read. --- mkpasswd.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mkpasswd.c b/mkpasswd.c index 8e56323..bbd155d 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -354,7 +354,7 @@ int main(int argc, char *argv[]) void* get_random_bytes(const unsigned int count) { char *buf; - int fd; + int fd, bytes_read; buf = NOFAIL(malloc(count)); fd = open(RANDOM_DEVICE, O_RDONLY); @@ -362,11 +362,13 @@ void* get_random_bytes(const unsigned int count) perror("open(" RANDOM_DEVICE ")"); exit(2); } - if (read(fd, buf, count) != count) { - if (count < 0) - perror("read(" RANDOM_DEVICE ")"); - else - fprintf(stderr, "Short read of %s.\n", RANDOM_DEVICE); + bytes_read = read(fd, buf, count); + if (bytes_read < 0) { + perror("read(" RANDOM_DEVICE ")"); + exit(2); + } + if (bytes_read != count) { + fprintf(stderr, "Short read of %s.\n", RANDOM_DEVICE); exit(2); } close(fd); From 512005132456507e1360d2d24478e75c4d2e6e9f Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 01:10:42 +0200 Subject: [PATCH 06/14] mkpasswd: fix a memory leak --- mkpasswd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mkpasswd.c b/mkpasswd.c index bbd155d..2e3ca80 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -387,6 +387,7 @@ void generate_salt(char *const buf, const unsigned int len) for (i = 0; i < len; i++) buf[i] = valid_salts[entropy[i] % (sizeof valid_salts - 1)]; buf[i] = '\0'; + free(entropy); } #else /* RANDOM_DEVICE */ From c7769cbfdf68a122d5d4ebf587d1273bda060b57 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 01:21:18 +0200 Subject: [PATCH 07/14] make is_new_gtld() return the TLD --- whois.c | 19 ++++++------------- whois.h | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/whois.c b/whois.c index 8097080..9248e5a 100644 --- a/whois.c +++ b/whois.c @@ -392,7 +392,7 @@ char *guess_server(const char *s) { unsigned long ip, as32; unsigned int i; - const char *colon; + const char *colon, *tld; /* IPv6 address */ if ((colon = strchr(s, ':'))) { @@ -460,16 +460,9 @@ char *guess_server(const char *s) return strdup(tld_serv[i + 1]); /* use the default server name for "new" gTLDs */ - if (is_new_gtld(s)) { - char *server; - const char *p, *tld = NULL; - - for (p = s; *p; p++) /* look for the TLD */ - if (*p == '.') - tld = p; - - server = malloc(strlen("whois.nic") + strlen(tld) + 1); - strcpy(server, "whois.nic"); + if ((tld = is_new_gtld(s))) { + char *server = malloc(strlen("whois.nic.") + strlen(tld) + 1); + strcpy(server, "whois.nic."); strcat(server, tld); return(server); } @@ -983,13 +976,13 @@ int domcmp(const char *dom, const char *tld) return 0; } -int is_new_gtld(const char *s) +const char *is_new_gtld(const char *s) { int i; for (i = 0; new_gtlds[i]; i++) if (domcmp(s, new_gtlds[i])) - return 1; + return new_gtlds[i] + 1; return 0; } diff --git a/whois.h b/whois.h index bf0dc13..3fd49bb 100644 --- a/whois.h +++ b/whois.h @@ -29,7 +29,7 @@ unsigned long myinet_aton(const char *); unsigned long asn32_to_long(const char *); int isasciidigit(const char); int domcmp(const char *, const char *); -int is_new_gtld(const char *); +const char *is_new_gtld(const char *); int domfind(const char *, const char *[]); char *normalize_domain(const char *); char *convert_6to4(const char *); From fa011e0665bea2f0298d72569d4f517a3fac6b94 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 01:56:42 +0200 Subject: [PATCH 08/14] Use the first referral of Afilias GRS results Defensive programming: this is never supposed to happen, but if more than one attribute were returned by the registry then the memory allocated to referral_server would be leaked. --- whois.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/whois.c b/whois.c index 9248e5a..66277f4 100644 --- a/whois.c +++ b/whois.c @@ -772,6 +772,8 @@ char *query_afilias(const int sock, const char *query) free(temp); while (fgets(buf, sizeof(buf), fi)) { + /* If multiple attributes are returned then use the first result. + This is not supposed to happen. */ if (state == 0 && strneq(buf, "Domain Name:", 12)) state = 1; if (state == 1 && strneq(buf, "Whois Server:", 13)) { @@ -780,8 +782,11 @@ char *query_afilias(const int sock, const char *query) referral_server = strdup(p); if ((p = strpbrk(referral_server, "\r\n "))) *p = '\0'; + state = 2; } + /* the output must not be hidden or no data will be shown for + host records and not-existing domains */ if (hide_line(&hide, buf)) continue; From ec1d53f1ba698e9b4d8be3c378e3f6bcbb93e5db Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Thu, 7 Aug 2014 04:39:53 +0200 Subject: [PATCH 09/14] Update the list of new gTLDs --- new_gtlds_list | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/new_gtlds_list b/new_gtlds_list index 8b008e9..df530c0 100644 --- a/new_gtlds_list +++ b/new_gtlds_list @@ -31,10 +31,13 @@ black blackfriday blue bmw +bnpparibas +boo boutique brussels build builders +business buzz bzh cab @@ -43,6 +46,7 @@ camp cancerresearch capetown capital +caravan cards care career @@ -51,6 +55,7 @@ cash catering center ceo +cern cheap christmas church @@ -58,6 +63,7 @@ citic city claims cleaning +click clinic clothing club @@ -80,8 +86,11 @@ credit creditcard cruises cuisinella +cymru +dad dance dating +day deals degree democrat @@ -89,6 +98,7 @@ dental dentist desi diamonds +diet digital direct directory @@ -96,12 +106,14 @@ discount dnp domains durban +eat education email engineer engineering enterprises equipment +esq estate eus events @@ -120,19 +132,24 @@ flights florist foo foundation +frl frogans fund furniture futbol gal gallery +gbiz gent gift +gifts gives glass global globo +gmail gmo +gmx gop graphics gratis @@ -144,6 +161,8 @@ guru hamburg haus healthcare +help +here hiphop hiv holdings @@ -151,10 +170,14 @@ holiday homes horse host +hosting house +how +immo immobilien industries info +ing ink institute insure @@ -183,6 +206,7 @@ link loans london lotto +ltda luxe luxury maison @@ -193,6 +217,7 @@ marketing media meet melbourne +meme menu miami mini @@ -202,10 +227,13 @@ monash mortgage moscow motorcycles +mov nagoya navy net +network neustar +new ngo nhk ninja @@ -215,12 +243,15 @@ nyc okinawa ong onl +ooo org organic +otsuka ovh paris partners parts +pharmacy photo photography photos @@ -228,12 +259,15 @@ physio pics pictures pink +pizza place plumbing praxi press +prod productions properties +property pub qpon quebec @@ -249,14 +283,18 @@ repair report republican rest +restaurant reviews rich rio rocks rodeo +rsvp ruhr ryukyu saarland +sarl +sca scb schmidt schule @@ -281,6 +319,7 @@ surf surgery suzuki systems +tatar tattoo tax technology @@ -290,12 +329,14 @@ tirol today tokyo tools +top town toys trade training university uno +uol vacations vegas ventures @@ -310,6 +351,7 @@ vote voting voto voyage +wales wang watch webcam @@ -319,9 +361,11 @@ whoswho wien wiki williamhill +wme works wtc wtf +xn--1qqw23a xn--3bst00m xn--3ds443g xn--4gbrim @@ -350,9 +394,12 @@ xn--q9jyb4c xn--rhqv96g xn--ses554g xn--unup4y +xn--vhquv +xn--xhq521b xn--zfr164b xyz yachts yandex yokohama +youtube zone From 1ae06d1a5a633a9efe7544a671f1885e00320094 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 04:42:33 +0200 Subject: [PATCH 10/14] Move longopts into main() --- whois.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/whois.c b/whois.c index 66277f4..c36ffd2 100644 --- a/whois.c +++ b/whois.c @@ -71,23 +71,25 @@ int hide_discl = HIDE_DISABLED; const char *client_tag = IDSTRING; -#ifdef HAVE_GETOPT_LONG -static const struct option longopts[] = { - {"version", no_argument, NULL, 1 }, - {"verbose", no_argument, NULL, 2 }, - {"help", no_argument, NULL, 3 }, - {"server", required_argument, NULL, 'h'}, - {"host", required_argument, NULL, 'h'}, - {"port", required_argument, NULL, 'p'}, - {NULL, 0, NULL, 0 } -}; -#else +#ifndef HAVE_GETOPT_LONG extern char *optarg; extern int optind; #endif int main(int argc, char *argv[]) { +#ifdef HAVE_GETOPT_LONG + const struct option longopts[] = { + {"version", no_argument, NULL, 1 }, + {"verbose", no_argument, NULL, 2 }, + {"help", no_argument, NULL, 3 }, + {"server", required_argument, NULL, 'h'}, + {"host", required_argument, NULL, 'h'}, + {"port", required_argument, NULL, 'p'}, + {NULL, 0, NULL, 0 } + }; +#endif + int ch, nopar = 0, fstringlen = 64; const char *server = NULL, *port = NULL; char *qstring, *fstring; From 833af3d94aca397255b254e0ca85f4a56881585b Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 04:44:13 +0200 Subject: [PATCH 11/14] Implement support for the long RIPE flags --- whois.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/whois.c b/whois.c index c36ffd2..f7e3332 100644 --- a/whois.c +++ b/whois.c @@ -80,14 +80,50 @@ int main(int argc, char *argv[]) { #ifdef HAVE_GETOPT_LONG const struct option longopts[] = { + /* program flags */ {"version", no_argument, NULL, 1 }, {"verbose", no_argument, NULL, 2 }, {"help", no_argument, NULL, 3 }, {"server", required_argument, NULL, 'h'}, {"host", required_argument, NULL, 'h'}, {"port", required_argument, NULL, 'p'}, + /* long RIPE flags */ + {"exact", required_argument, NULL, 'x'}, + {"all-more", required_argument, NULL, 'M'}, + {"one-more", required_argument, NULL, 'm'}, + {"all-less", required_argument, NULL, 'L'}, + {"one-less", required_argument, NULL, 'l'}, + {"reverse-domain", required_argument, NULL, 'd'}, + {"irt", required_argument, NULL, 'c'}, + {"abuse-contact", no_argument, NULL, 'b'}, + {"brief", no_argument, NULL, 'F'}, + {"primary-keys", no_argument, NULL, 'K'}, + {"persistent-connection", no_argument, NULL, 'k'}, + {"no-referenced", no_argument, NULL, 'r'}, + {"no-filtering", no_argument, NULL, 'B'}, + {"no-grouping", no_argument, NULL, 'G'}, + {"select-types", no_argument, NULL, 'T'}, + {"all-sources", no_argument, NULL, 'a'}, + {"sources", no_argument, NULL, 's'}, + {"types", no_argument, NULL, 12 }, /* -q */ + {"ripe-version", no_argument, NULL, 12 }, /* -q */ + {"list-sources", no_argument, NULL, 12 }, /* -q */ + {"template", required_argument, NULL, 't'}, + {"ripe-verbose", required_argument, NULL, 'v'}, + /* long RIPE flags with no short equivalent */ + {"list-versions", no_argument, NULL, 10 }, + {"diff-versions", required_argument, NULL, 11 }, + {"show-version", required_argument, NULL, 11 }, + {"resource", no_argument, NULL, 10 }, + {"show-personal", no_argument, NULL, 10 }, + {"no-personal", no_argument, NULL, 10 }, + {"show-tag-info", no_argument, NULL, 10 }, + {"no-tag-info", no_argument, NULL, 10 }, + {"filter-tag-include", required_argument, NULL, 11 }, + {"filter-tag-exclude", required_argument, NULL, 11 }, {NULL, 0, NULL, 0 } }; + int longindex; #endif int ch, nopar = 0, fstringlen = 64; @@ -108,7 +144,8 @@ int main(int argc, char *argv[]) argv = merge_args(getenv("WHOIS_OPTIONS"), argv, &argc); while ((ch = GETOPT_LONGISH(argc, argv, - "abBcdFg:Gh:Hi:KlLmMp:q:rRs:t:T:v:V:x", longopts, 0)) > 0) { + "abBcdFg:Gh:Hi:KlLmMp:q:rRs:t:T:v:V:x", + longopts, &longindex)) > 0) { /* RIPE flags */ if (strchr(ripeflags, ch)) { if (strlen(fstring) + 3 > fstringlen) { @@ -129,8 +166,37 @@ int main(int argc, char *argv[]) nopar = 1; continue; } - /* program flags */ switch (ch) { +#ifdef HAVE_GETOPT_LONG + /* long RIPE flags with no short equivalent */ + case 12: + nopar = 1; + /* fall through */ + case 10: + { + int flaglen = 2 + strlen(longopts[longindex].name) + 1; + if (strlen(fstring) + flaglen > fstringlen) { + fstringlen += flaglen; + fstring = realloc(fstring, fstringlen + 1); + } + sprintf(fstring + strlen(fstring), "--%s ", + longopts[longindex].name); + } + break; + case 11: + { + int flaglen = 2 + strlen(longopts[longindex].name) + 1 + + strlen(optarg) + 1; + if (strlen(fstring) + flaglen > fstringlen) { + fstringlen += flaglen; + fstring = realloc(fstring, fstringlen + 1); + } + sprintf(fstring + strlen(fstring), "--%s %s ", + longopts[longindex].name, optarg); + } + break; +#endif + /* program flags */ case 'h': server = strdup(optarg); break; From 2dc046b070fb751c2bba2b9352b117ac6e836cb7 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 04:59:04 +0200 Subject: [PATCH 12/14] Update make_version_h.pl to support Debian binNMUs --- make_version_h.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/make_version_h.pl b/make_version_h.pl index 9eef4a8..06c7841 100755 --- a/make_version_h.pl +++ b/make_version_h.pl @@ -2,17 +2,18 @@ use warnings; use strict; +use autodie; my $changelog = $ARGV[0] or die "Usage: $0 debian/changelog\n"; -open(my $fh, '<', $changelog) or die "open($changelog): $!"; +open(my $fh, '<', $changelog); my $line = <$fh>; -close($fh) or die "close($changelog): $!"; +close($fh); my ($ver) = $line =~ /^whois \s+ \( ( [^\)]+ ) \) \s+ \S+/x; die "Version number not found in $changelog!\n" if not $ver; -$ver =~ s/ ( ~bpo\d+\+\d+ | ~deb\d+.* | ubuntu\d+ | \+dyson\d+ ) $//x; +$ver =~ s/ ( ~bpo\d+\+\d+ | \+b\d+ | ~deb\d+.* | ubuntu\d+ | \+dyson\d+ ) $//x; # The version number must not deviate from this format or the -V option # to RIPE-like servers will break. If needed, update the previous regexp. From 33f174e956c018186294ce13563e6b795b014f60 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 05:04:54 +0200 Subject: [PATCH 13/14] Default to whois.ripe.net when using long flags --- whois.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/whois.c b/whois.c index f7e3332..c3d2a1d 100644 --- a/whois.c +++ b/whois.c @@ -255,8 +255,8 @@ int main(int argc, char *argv[]) if (getenv("WHOIS_HIDE")) hide_discl = HIDE_NOT_STARTED; - /* -v or -t has been used */ - if (!server && !*qstring) + /* -v or -t or long flags have been used */ + if (!server && (!*qstring || *fstring)) server = strdup("whois.ripe.net"); if (*qstring) { From 3957648d372db49208037bbc8fc125b8235806c2 Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sat, 13 Sep 2014 05:10:20 +0200 Subject: [PATCH 14/14] Debian changelog for 5.2.0 --- debian/changelog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debian/changelog b/debian/changelog index 052404f..5ff9a1c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +whois (5.2.0) unstable; urgency=medium + + * Implemented support for the long RIPE flags. + * "Fixed" some harmless bugs discovered with a Coverity scan. + * Default to whois.ripe.net when using long flags. + * Updated the list of new gTLDs. + * Added a new ASN allocation. + * Added new recovered IPv4 allocations. + * Updated make_version_h.pl to support Debian binNMUs. (Closes: #761318) + + -- Marco d'Itri Sat, 13 Sep 2014 05:05:16 +0200 + whois (5.1.5) unstable; urgency=medium * Updated the list of new gTLDs.