From a0c70ba37b7af378630ca2e30a455ef3a5462f6d Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Fri, 27 Dec 2024 07:31:24 -0500 Subject: [PATCH] Tighter code --- sniff2ban.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sniff2ban.c b/sniff2ban.c index b56866c..91a9665 100644 --- a/sniff2ban.c +++ b/sniff2ban.c @@ -2526,16 +2526,14 @@ setup_apache_hosts(void) while(fgets(buf, sizeof(buf) - 1, fin) != NULL) { char *p, *q; - p = strstr(buf, "ServerName"); - if(p) + /* Locate ServerName or ServerAlias */ + if((p = strstr(buf, "ServerName")) != NULL) p = &p[10]; - else { - p = strstr(buf, "ServerAlias"); - if(p) - p = &p[11]; - if(p == NULL) - continue; - } + else if((p = strstr(buf, "ServerAlias")) != NULL) + p = &p[11]; + else + continue; + while(isspace(*p)) p++; if(*p == '\0')