Viktor Dukhovni:
> On Tue, Feb 14, 2017 at 09:43:25PM +0100, Matthias Schneider wrote:
> > Hi Viktor,
> >
> > i applyed the patch and after connecting to port 25 i'll get:
> >
>
> Yes, sorry, the original patch is buggy, it fails to initialize
> "cname" for already canonical (enclosed in {}) multi-char names.
> Try this one instead:
>
> diff --git a/src/milter/milter.c b/src/milter/milter.c
> index 64836d4..571db7a 100644
> --- a/src/milter/milter.c
> +++ b/src/milter/milter.c
> @@ -333,16 +333,19 @@ static ARGV *milter_macro_lookup(MILTERS *milters,
> const char *macro_names)
> VSTRING *canon_buf = vstring_alloc(20);
> const char *value;
> const char *name;
> + const char *cname;
>
> while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) {
> if (msg_verbose)
> msg_info("%s: \"%s\"", myname, name);
> if (*name != '{') /* } */
> - name = STR(vstring_sprintf(canon_buf, "{%s}", name));
> - if ((value = milters->mac_lookup(name, milters->mac_context)) != 0) {
> + cname = STR(vstring_sprintf(canon_buf, "{%s}", name));
> + else
> + cname = name;
> + if ((value = milters->mac_lookup(cname, milters->mac_context)) != 0) {
> if (msg_verbose)
> msg_info("%s: result \"%s\"", myname, value);
> - argv_add(argv, name, value, (char *) 0);
> + argv_add(argv, name[1] == '\0' ? name : cname, value, (char *) 0);
> } else if (milters->macro_defaults != 0
> && (value = htable_find(milters->macro_defaults, name)) != 0) {
> if (msg_verbose)
This breaks milter_macro_defaults lookups, which always require the
form {name}. This would have been found immediately if the library
had tests.
Wietse