From: Frédéric Marchal Date: Mon, 13 Feb 2012 08:03:00 +0000 (+0100) Subject: Display an error message if a regex is used in the hostalias X-Git-Tag: v2.3.3-pre1~24^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a9567aa0d6c585242a1c18463eff1c184e867dc4;p=thirdparty%2Fsarg.git Display an error message if a regex is used in the hostalias If libpcre was not compiled in sarg and regex are used in the hostalias file, an error message is displayed and sarg exits. --- diff --git a/url.c b/url.c index 794dfed..668e063 100644 --- a/url.c +++ b/url.c @@ -531,27 +531,30 @@ static int Alias_Store(char *buf) const char *next; int Error; + if (strncasecmp(buf,"re:",3)==0) { #ifdef USE_PCRE - if (strncasecmp(buf,"re:",3)==0) { - if (Alias_StoreRegexp(buf+3)<0) - return(-1); - return(0); - } -#endif - type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next); - if (type<0) { + if (Alias_StoreRegexp(buf+3)<0) return(-1); - } - - if (type==1) { - Error=Alias_StoreName(name,next); - } else if (type==2) { - Error=Alias_StoreIpv4(ipv4,nbits,next); - } else if (type==3) { - Error=Alias_StoreIpv6(ipv6,nbits,next); - } - if (Error<0) return(-1); return(0); +#else + debuga(_("PCRE not compiled in therefore the regular expressions are not available in the host alias file\n")); + return(-1); +#endif + } + type=extract_address_mask(buf,&name,ipv4,ipv6,&nbits,&next); + if (type<0) { + return(-1); + } + + if (type==1) { + Error=Alias_StoreName(name,next); + } else if (type==2) { + Error=Alias_StoreIpv4(ipv4,nbits,next); + } else if (type==3) { + Error=Alias_StoreIpv6(ipv6,nbits,next); + } + if (Error<0) return(-1); + return(0); } /*!