From 718ae61ae551c72defdbe774d4958c687c6f976f Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Tue, 8 Dec 2015 08:38:50 +0100 Subject: Support american fuzzy lop When built with AFL_MODE set to true, whois will use the first line of standard input as command line parameters and the rest as network input. --- utils.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'utils.h') diff --git a/utils.h b/utils.h index 0f226ae..4523266 100644 --- a/utils.h +++ b/utils.h @@ -9,6 +9,10 @@ #define NOFAIL(ptr) do_nofail((ptr), __FILE__, __LINE__) +#ifndef AFL_MODE +# define AFL_MODE 0 +#endif + /* Portability macros */ #ifdef __GNUC__ # define NORETURN __attribute__((noreturn)) -- cgit v1.2.3 From fb823a251a224a14553f2551c5b6fdd199f3185d Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Sun, 26 Feb 2017 23:33:01 +0100 Subject: Annotate more functions with NORETURN Contributed by Sami Kerola. Closes #48 from Github. --- mkpasswd.c | 4 ++-- utils.c | 4 ++-- utils.h | 4 ++-- whois.c | 6 +++--- whois.h | 8 +++++--- 5 files changed, 14 insertions(+), 12 deletions(-) (limited to 'utils.h') diff --git a/mkpasswd.c b/mkpasswd.c index 8066c81..5b31ddc 100644 --- a/mkpasswd.c +++ b/mkpasswd.c @@ -124,7 +124,7 @@ static const struct crypt_method methods[] = { void generate_salt(char *const buf, const unsigned int len); void *get_random_bytes(const unsigned int len); -void display_help(int error); +void NORETURN display_help(int error); void display_version(void); void display_methods(void); @@ -438,7 +438,7 @@ void generate_salt(char *const buf, const unsigned int len) #endif /* RANDOM_DEVICE || HAVE_ARC4RANDOM_BUF */ -void display_help(int error) +void NORETURN display_help(int error) { fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _("Usage: mkpasswd [OPTIONS]... [PASSWORD [SALT]]\n" diff --git a/utils.c b/utils.c index e29749e..4ade650 100644 --- a/utils.c +++ b/utils.c @@ -73,7 +73,7 @@ char **merge_args(char *args, char *argv[], int *argc) } /* Error routines */ -void err_sys(const char *fmt, ...) +void NORETURN err_sys(const char *fmt, ...) { va_list ap; @@ -84,7 +84,7 @@ void err_sys(const char *fmt, ...) exit(2); } -void err_quit(const char *fmt, ...) +void NORETURN err_quit(const char *fmt, ...) { va_list ap; diff --git a/utils.h b/utils.h index 4523266..3266324 100644 --- a/utils.h +++ b/utils.h @@ -54,7 +54,7 @@ void *do_nofail(void *ptr, const char *file, const int line); char **merge_args(char *args, char *argv[], int *argc); -void err_quit(const char *fmt, ...) NORETURN; -void err_sys(const char *fmt, ...) NORETURN; +void NORETURN err_quit(const char *fmt, ...); +void NORETURN err_sys(const char *fmt, ...); #endif diff --git a/whois.c b/whois.c index 897a7ed..adcf5e7 100644 --- a/whois.c +++ b/whois.c @@ -1051,13 +1051,13 @@ int connect_with_timeout(int fd, const struct sockaddr *addr, return 0; } -void alarm_handler(int signum) +void NORETURN alarm_handler(int signum) { close(sockfd); err_quit(_("Timeout.")); } -void sighandler(int signum) +void NORETURN sighandler(int signum) { close(sockfd); err_quit(_("Interrupted by signal %d..."), signum); @@ -1379,7 +1379,7 @@ int isasciidigit(const char c) { /* http://www.ripe.net/ripe/docs/databaseref-manual.html */ -void usage(int error) +void NORETURN usage(int error) { fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _( "Usage: whois [OPTION]... OBJECT...\n\n" diff --git a/whois.h b/whois.h index b384152..a33a241 100644 --- a/whois.h +++ b/whois.h @@ -1,3 +1,5 @@ +#include "utils.h" + /* 6bone referto: extension */ #define REFERTO_FORMAT "%% referto: whois -h %255s -p %15s %1021[^\n\r]" @@ -21,9 +23,9 @@ char *query_crsnic(const int, const char *); char *query_afilias(const int, const char *); int openconn(const char *, const char *); int connect_with_timeout(int, const struct sockaddr *, socklen_t, int); -void usage(int error); -void alarm_handler(int); -void sighandler(int); +void NORETURN usage(int error); +void NORETURN alarm_handler(int); +void NORETURN sighandler(int); int japanese_locale(void); unsigned long myinet_aton(const char *); unsigned long asn32_to_long(const char *); -- cgit v1.2.3 From 8ed6d730959b1f988dd43a511c40b9419bb2b0db Mon Sep 17 00:00:00 2001 From: Marco d'Itri Date: Mon, 27 Feb 2017 00:32:43 +0100 Subject: Implement support for libidn2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contributed by Tim Rühsen. Closes #49 from Github. --- Makefile | 5 +++++ utils.h | 3 +++ whois.c | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'utils.h') diff --git a/Makefile b/Makefile index 28eb36f..74ccb00 100644 --- a/Makefile +++ b/Makefile @@ -32,10 +32,15 @@ ifdef LOCALEDIR DEFS += -DLOCALEDIR=\"$(BASEDIR)$(prefix)/share/locale\" endif +ifdef HAVE_LIBIDN2 +whois_LDADD += -lidn2 +DEFS += -DHAVE_LIBIDN2 +else ifdef HAVE_LIBIDN whois_LDADD += -lidn DEFS += -DHAVE_LIBIDN endif +endif ifdef HAVE_ICONV whois_OBJECTS += simple_recode.o diff --git a/utils.h b/utils.h index 3266324..32055b3 100644 --- a/utils.h +++ b/utils.h @@ -49,6 +49,9 @@ # define ngettext(a, b, c) ((c==1) ? (a) : (b)) #endif +#if defined IDN2_VERSION_NUMBER && IDN2_VERSION_NUMBER < 0x00140000 +# define IDN2_NONTRANSITIONAL IDN2_NFC_INPUT +#endif /* Prototypes */ void *do_nofail(void *ptr, const char *file, const int line); diff --git a/whois.c b/whois.c index 06346ed..8f5f1f1 100644 --- a/whois.c +++ b/whois.c @@ -31,7 +31,9 @@ #ifdef HAVE_REGEXEC #include #endif -#ifdef HAVE_LIBIDN +#ifdef HAVE_LIBIDN2 +#include +#elif defined HAVE_LIBIDN #include #endif #ifdef HAVE_INET_PTON @@ -654,7 +656,7 @@ char *queryformat(const char *server, const char *flags, const char *query) simple_recode_input_charset = "utf-8"; /* then try UTF-8 */ #endif -#ifdef HAVE_LIBIDN +#if defined HAVE_LIBIDN || defined HAVE_LIBIDN2 # define DENIC_PARAM_ACE ",ace" #else # define DENIC_PARAM_ACE "" @@ -1144,7 +1146,7 @@ const char *is_new_gtld(const char *s) char *normalize_domain(const char *dom) { char *p, *ret; -#ifdef HAVE_LIBIDN +#if defined HAVE_LIBIDN || defined HAVE_LIBIDN2 char *domain_start = NULL; #endif @@ -1159,7 +1161,7 @@ char *normalize_domain(const char *dom) p--; } -#ifdef HAVE_LIBIDN +#if defined HAVE_LIBIDN || defined HAVE_LIBIDN2 /* find the start of the last word if there are spaces in the query */ for (p = ret; *p; p++) if (*p == ' ') @@ -1169,8 +1171,13 @@ char *normalize_domain(const char *dom) char *q, *r; int prefix_len; +#ifdef HAVE_LIBIDN2 + if (idn2_lookup_ul(domain_start, &q, IDN2_NONTRANSITIONAL) != IDN2_OK) + return ret; +#else if (idna_to_ascii_lz(domain_start, &q, 0) != IDNA_SUCCESS) return ret; +#endif /* reassemble the original query in a new buffer */ prefix_len = domain_start - ret; @@ -1185,8 +1192,13 @@ char *normalize_domain(const char *dom) } else { char *q; +#ifdef HAVE_LIBIDN2 + if (idn2_lookup_ul(ret, &q, IDN2_NONTRANSITIONAL) != IDN2_OK) + return ret; +#else if (idna_to_ascii_lz(ret, &q, 0) != IDNA_SUCCESS) return ret; +#endif free(ret); return q; -- cgit v1.2.3