X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/0f4b9af077461d8098f6868c69243551e6f500ee..4e23ddd4d595d50de4b7fa0ab6bf3533bcf42723:/sbr/mf.c diff --git a/sbr/mf.c b/sbr/mf.c index f993c235..c8868178 100644 --- a/sbr/mf.c +++ b/sbr/mf.c @@ -8,14 +8,11 @@ */ #include -#include -#include #include /* * static prototypes */ -static char *getcpy (const char *); static int isat (const char *); static int parse_address (void); static int phrase (char *); @@ -24,25 +21,7 @@ static int local_part (char *); static int domain (char *); static int route (char *); static int my_lex (char *); - - -static char * -getcpy (const char *s) -{ - register char *p; - - if (!s) { -/* causes compiles to blow up because the symbol _cleanup is undefined - where did this ever come from? */ - /* _cleanup(); */ - abort(); - for(;;) - pause(); - } - p = mh_xmalloc ((size_t) (strlen (s) + 2)); - strcpy (p, s); - return p; -} +static int contains8bit (const char *); int @@ -218,7 +197,7 @@ getadrx (const char *addrs) err[0] = 0; if (dp == NULL) { - dp = cp = getcpy (addrs ? addrs : ""); + dp = cp = strdup (addrs ? addrs : ""); glevel = 0; } else @@ -252,6 +231,15 @@ getadrx (const char *addrs) break; } + /* + * Reject the address if key fields contain 8bit characters + */ + + if (contains8bit(mbox) || contains8bit(host) || contains8bit(path) || + contains8bit(grp)) { + strcpy(err, "Address contains 8-bit characters"); + } + if (err[0]) for (;;) { switch (last_lex) { @@ -299,7 +287,7 @@ again: ; switch (my_lex (buffer)) { case LX_ATOM: case LX_QSTR: - pers = getcpy (buffer); + pers = strdup (buffer); break; case LX_SEMI: @@ -553,7 +541,7 @@ domain (char *buffer) static int route (char *buffer) { - path = getcpy ("@"); + path = strdup ("@"); for (;;) { switch (my_lex (buffer)) { @@ -652,7 +640,7 @@ my_lex (char *buffer) if (--i < 0) { *bp = 0; note = note ? add (buffer, add (" ", note)) - : getcpy (buffer); + : strdup (buffer); return my_lex (buffer); } } @@ -740,6 +728,25 @@ got_atom: ; } +/* + * Return true if the string contains an 8-bit character + */ + +static int +contains8bit(const char *p) +{ + if (! p) + return 0; + + for (; *p; p++) { + if (! isascii((unsigned char) *p)) + return 1; + } + + return 0; +} + + char * legal_person (const char *p) {