From 0b571f0ad5550d5453937b04c089d49abee84a14 Mon Sep 17 00:00:00 2001 From: ThiefMaster Date: Mon, 7 Sep 2009 13:25:49 +0200 Subject: [PATCH] Get rid of ugly goto in opt_fakehost. --- src/nickserv.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/nickserv.c b/src/nickserv.c index 4675b8b..0144fba 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -2650,10 +2650,14 @@ static OPTION_FUNC(opt_fakehost) safestrncpy(mask, argv[1], sizeof(mask)); if ((host = strrchr(mask, '@')) && host != mask) { - if(!oper_has_access(user, nickserv, nickserv_conf.set_fakeident_level, 0)) - goto no_access; - ident = mask; - *host++ = '\0'; + // If ident@host was used and the user doesn't have access to set idents, do not change anything. + if (!oper_has_access(user, nickserv, nickserv_conf.set_fakeident_level, 0)) { + host = NULL; + ident = NULL; + } else { + ident = mask; + *host++ = '\0'; + } } else { ident = NULL; host = mask; @@ -2664,12 +2668,12 @@ static OPTION_FUNC(opt_fakehost) return 0; } - if ((strlen(host) > HOSTLEN) || (host[0] == '.')) { + if (host && ((strlen(host) > HOSTLEN) || (host[0] == '.'))) { send_message(user, nickserv, "NSMSG_FAKEHOST_INVALID", HOSTLEN); return 0; } - if (host[0]) { + if (host && host[0]) { free(hi->fakehost); if (!strcmp(host, "*")) hi->fakehost = NULL; @@ -2693,7 +2697,6 @@ static OPTION_FUNC(opt_fakehost) apply_fakehost(hi, NULL); } else { -no_access: host = generate_fakehost(hi); ident = generate_fakeident(hi, NULL); } -- 2.20.1