Viktor Dukhovni: > On Wed, Sep 22, 2021 at 10:35:45PM +1000, raf wrote: > > > I just encountered a wierd thing (debian-11 stable, postfix-3.5.6-1+b1). > > Thanks for the bug report. > > > $ postconf -xdf proxy_read_maps > > proxy_read_maps = all127.0.0.0/8 a.b.c.d/32 [::1]/128 > > [a:b:c:d::e]/128 [fe80::]/64 hash:/etc/aliases, nis:mail.aliases > > The problem is an recursive reuse of a static buffer in the postconf(1) > code (does not affect any other Postfix programs, ...) that expands the > default value of mynetworks, when called recursively from expanding some > other parameter. > > Patch below.
Thanks. This is the result of lazy coding in a nasty language. I should stop hidden static buffers, or switch to a language has automatic destructors like C++ or Go. Wietse > -- > Viktor. > > --- a/src/postconf/postconf_builtin.c > +++ b/src/postconf/postconf_builtin.c > @@ -250,6 +250,7 @@ static const char *pcf_check_mydomainname(void) > static const char *pcf_mynetworks(void) > { > static const char *networks; > + static VSTRING *local_buf; > const char *junk; > > /* > @@ -258,10 +259,13 @@ static const char *pcf_mynetworks(void) > if (networks) > return (networks); > > + if (local_buf == 0) > + local_buf = vstring_alloc(100); > + > if (var_inet_interfaces == 0) { > if ((pcf_cmd_mode & PCF_SHOW_DEFS) > || (junk = mail_conf_lookup_eval(VAR_INET_INTERFACES)) == 0) > - junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode, > + junk = pcf_expand_parameter_value(local_buf, pcf_cmd_mode, > DEF_INET_INTERFACES, > (PCF_MASTER_ENT *) 0); > var_inet_interfaces = mystrdup(junk); > @@ -269,7 +273,7 @@ static const char *pcf_mynetworks(void) > if (var_mynetworks_style == 0) { > if ((pcf_cmd_mode & PCF_SHOW_DEFS) > || (junk = mail_conf_lookup_eval(VAR_MYNETWORKS_STYLE)) == 0) > - junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode, > + junk = pcf_expand_parameter_value(local_buf, pcf_cmd_mode, > DEF_MYNETWORKS_STYLE, > (PCF_MASTER_ENT *) 0); > var_mynetworks_style = mystrdup(junk); > @@ -277,7 +281,7 @@ static const char *pcf_mynetworks(void) > if (var_inet_protocols == 0) { > if ((pcf_cmd_mode & PCF_SHOW_DEFS) > || (junk = mail_conf_lookup_eval(VAR_INET_PROTOCOLS)) == 0) > - junk = pcf_expand_parameter_value((VSTRING *) 0, pcf_cmd_mode, > + junk = pcf_expand_parameter_value(local_buf, pcf_cmd_mode, > DEF_INET_PROTOCOLS, > (PCF_MASTER_ENT *) 0); > var_inet_protocols = mystrdup(junk); >