X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c6f2d14d9c38345075629af3487c2de491584ca1..bf4e14adcab829c23f134253dea686789eb21d6a:/uip/aliasbr.c?ds=sidebyside diff --git a/uip/aliasbr.c b/uip/aliasbr.c index 8462fbdc..ab2130ef 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -1,6 +1,4 @@ - -/* - * aliasbr.c -- new aliasing mechanism +/* aliasbr.c -- new aliasing mechanism * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -112,7 +110,9 @@ akval (struct aka *ak, char *s) for (; ak; ak = ak->ak_next) { if (aleq (s, ak->ak_name)) { return akresult (ak); - } else if (strchr (s, ':')) { + } + + if (strchr (s, ':')) { /* The first address in a blind list will contain the alias name, so try to match, but just with just the address (not including the list name). If there's a @@ -130,6 +130,8 @@ akval (struct aka *ak, char *s) if (mp && mp->m_ingrp) { char *gname = add (mp->m_gname, NULL); + /* FIXME: gname must be true; add() never returns NULL. + * Is some other test required? */ if (gname && aleq (name, ak->ak_name)) { /* Will leak cp. */ cp = concat (gname, akresult (ak), NULL); @@ -149,7 +151,7 @@ akval (struct aka *ak, char *s) } } - return getcpy (s); + return mh_xstrdup(s); } @@ -158,14 +160,13 @@ aleq (char *string, char *aliasent) { char c; - while ((c = *string++)) + while ((c = *string++)) { if (*aliasent == '*') return 1; - else - if ((c | 040) != (*aliasent | 040)) - return 0; - else - aliasent++; + if (tolower((unsigned char)c) != tolower((unsigned char)*aliasent)) + return 0; + aliasent++; + } return (*aliasent == 0 || *aliasent == '*'); } @@ -181,7 +182,7 @@ alias (char *file) FILE *fp; if (*file != '/' - && (strncmp (file, "./", 2) && strncmp (file, "../", 3))) + && !has_prefix(file, "./") && !has_prefix(file, "../")) file = etcpath (file); if ((fp = fopen (file, "r")) == NULL) { akerrst = file; @@ -201,7 +202,7 @@ alias (char *file) fclose (fp); return i; } - + /* FALLTHRU */ case ':': /* comment */ case ';': case '#': @@ -479,7 +480,7 @@ add_aka (struct aka *ak, char *pp) return; NEW(ad); - ad->ad_text = getcpy (pp); + ad->ad_text = mh_xstrdup(pp); ad->ad_local = strchr(pp, '@') == NULL && strchr(pp, '!') == NULL; ad->ad_next = NULL; if (ak->ak_addr)