From: Wietse Venema Date: Fri, 31 Mar 2023 05:00:00 +0000 (-0500) Subject: postfix-3.8-20230331-nonprod X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d055f8511221f1d910a6f7955b8aeedd4b6d711a;p=thirdparty%2Fpostfix.git postfix-3.8-20230331-nonprod --- diff --git a/postfix/HISTORY b/postfix/HISTORY index 43198443a..b5d971172 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -26995,3 +26995,30 @@ Apologies for any names omitted. form "name = value" instead of the expected "name=value". Found during code maintenance. Also refined an "empty name" check. Files: clean_env.c, split_nameval.c. + + Safety: Postfix programs log a warning when a configuration + parameter specifies a list that contains a #comment. Examples + of such parameters are smtpd_*_restrictions, check_ccert_access, + and restriction_classes. This affects about 70 call sites + where a list is parsed. Files: proto/stop.spell-cc, + src/cleanup/cleanup_init.c, src/global/dict_ldap.c, + src/global/dict_mysql.c, src/global/dict_pgsql.c, + src/global/dynamicmaps.c, src/global/header_opts.c, + src/global/login_sender_match.c, src/global/mail_conf.c, + src/global/maillog_client.c, src/global/mail_parm_split.c, + src/global/mail_queue.c, src/global/maps.c, + src/global/map_search.c, src/global/own_inet_addr.c, + src/global/server_acl.c, src/local/dotforward.c, + src/master/master_ent.c, src/milter/milter8.c, src/milter/milter.c, + src/oqmgr/qmgr_message.c, src/postfix/postfix.c, + src/postmulti/postmulti.c, src/postscreen/postscreen_dnsbl.c, + src/postsuper/postsuper.c, src/proxymap/proxymap.c, + src/qmgr/qmgr_message.c, src/sendmail/sendmail.c, + src/smtpd/smtpd_check.c, src/smtp/smtp_connect.c, + src/smtp/smtp_tls_policy.c, src/tls/tls_certkey.c, + src/tls/tls_dane.c, src/util/argv.h, src/util/argv_split.c, + src/util/argv_splitq.c, src/util/dict_file.c, + src/util/dict_inline.c, src/util/dict_pipe.c, + src/util/dict_random.c, src/util/dict_stream.c, + src/util/dict_union.c, src/util/match_list.c, src/util/mystrtok.c, + src/util/name_mask.c, src/util/stringops.h. diff --git a/postfix/html/mailq.1.html b/postfix/html/mailq.1.html index bebc17b3f..e81149a07 100644 --- a/postfix/html/mailq.1.html +++ b/postfix/html/mailq.1.html @@ -455,9 +455,11 @@ SENDMAIL(1) SENDMAIL(1) The location of the Postfix top-level queue directory. remote_header_rewrite_domain (empty) - Don't rewrite message headers from remote clients at all when - this parameter is empty; otherwise, rewrite message headers and - append the specified domain name to incomplete addresses. + Rewrite or add message headers in mail from remote clients if + the remote_header_rewrite_domain parameter value is non-empty, + updating incomplete addresses with the domain specified in the + remote_header_rewrite_domain parameter, and adding missing head- + ers. syslog_facility (mail) The syslog facility of Postfix logging. @@ -519,5 +521,7 @@ SENDMAIL(1) SENDMAIL(1) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + SENDMAIL(1) diff --git a/postfix/html/newaliases.1.html b/postfix/html/newaliases.1.html index bebc17b3f..e81149a07 100644 --- a/postfix/html/newaliases.1.html +++ b/postfix/html/newaliases.1.html @@ -455,9 +455,11 @@ SENDMAIL(1) SENDMAIL(1) The location of the Postfix top-level queue directory. remote_header_rewrite_domain (empty) - Don't rewrite message headers from remote clients at all when - this parameter is empty; otherwise, rewrite message headers and - append the specified domain name to incomplete addresses. + Rewrite or add message headers in mail from remote clients if + the remote_header_rewrite_domain parameter value is non-empty, + updating incomplete addresses with the domain specified in the + remote_header_rewrite_domain parameter, and adding missing head- + ers. syslog_facility (mail) The syslog facility of Postfix logging. @@ -519,5 +521,7 @@ SENDMAIL(1) SENDMAIL(1) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + SENDMAIL(1) diff --git a/postfix/html/postfix.1.html b/postfix/html/postfix.1.html index 4654071fa..fa3752d87 100644 --- a/postfix/html/postfix.1.html +++ b/postfix/html/postfix.1.html @@ -451,5 +451,7 @@ POSTFIX(1) POSTFIX(1) The Linux PLD project Dean Strik, Eindhoven University, The Netherlands + Wietse Venema + POSTFIX(1) diff --git a/postfix/html/postmulti.1.html b/postfix/html/postmulti.1.html index 8ef57cf4a..d77a51bbf 100644 --- a/postfix/html/postmulti.1.html +++ b/postfix/html/postmulti.1.html @@ -406,5 +406,7 @@ POSTMULTI(1) POSTMULTI(1) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + POSTMULTI(1) diff --git a/postfix/html/postsuper.1.html b/postfix/html/postsuper.1.html index 30a524a4d..458e66a4f 100644 --- a/postfix/html/postsuper.1.html +++ b/postfix/html/postsuper.1.html @@ -275,7 +275,7 @@ POSTSUPER(1) POSTSUPER(1) subdirectory levels. import_environment (see 'postconf -d' output) - The list of environment parameters that a privileged Postfix + The list of environment variables that a privileged Postfix process will import from a non-Postfix parent process, or name=value environment overrides. @@ -314,5 +314,7 @@ POSTSUPER(1) POSTSUPER(1) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + POSTSUPER(1) diff --git a/postfix/html/proxymap.8.html b/postfix/html/proxymap.8.html index 7c98c47d6..c4b12e11f 100644 --- a/postfix/html/proxymap.8.html +++ b/postfix/html/proxymap.8.html @@ -219,5 +219,7 @@ PROXYMAP(8) PROXYMAP(8) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + PROXYMAP(8) diff --git a/postfix/html/sendmail.1.html b/postfix/html/sendmail.1.html index bebc17b3f..e81149a07 100644 --- a/postfix/html/sendmail.1.html +++ b/postfix/html/sendmail.1.html @@ -455,9 +455,11 @@ SENDMAIL(1) SENDMAIL(1) The location of the Postfix top-level queue directory. remote_header_rewrite_domain (empty) - Don't rewrite message headers from remote clients at all when - this parameter is empty; otherwise, rewrite message headers and - append the specified domain name to incomplete addresses. + Rewrite or add message headers in mail from remote clients if + the remote_header_rewrite_domain parameter value is non-empty, + updating incomplete addresses with the domain specified in the + remote_header_rewrite_domain parameter, and adding missing head- + ers. syslog_facility (mail) The syslog facility of Postfix logging. @@ -519,5 +521,7 @@ SENDMAIL(1) SENDMAIL(1) 111 8th Avenue New York, NY 10011, USA + Wietse Venema + SENDMAIL(1) diff --git a/postfix/makedefs b/postfix/makedefs index c8cc13d8a..48c92423c 100644 --- a/postfix/makedefs +++ b/postfix/makedefs @@ -969,7 +969,7 @@ CCARGS="$CCARGS -DSNAPSHOT" # Non-production: needs thorough testing, or major changes are still # needed before the code stabilizes. -#CCARGS="$CCARGS -DNONPROD" +CCARGS="$CCARGS -DNONPROD" # Workaround: prepend Postfix include files before other include files. CCARGS="-I. -I../../include $CCARGS" diff --git a/postfix/man/man1/postfix.1 b/postfix/man/man1/postfix.1 index c3ad0d8e9..318d5b6eb 100644 --- a/postfix/man/man1/postfix.1 +++ b/postfix/man/man1/postfix.1 @@ -432,3 +432,5 @@ Mark Huizer, Eindhoven University, The Netherlands Jun\-ichiro 'itojun' Hagino, KAME project, Japan The Linux PLD project Dean Strik, Eindhoven University, The Netherlands + +Wietse Venema diff --git a/postfix/man/man1/postmulti.1 b/postfix/man/man1/postmulti.1 index 6db035ea1..3f3343742 100644 --- a/postfix/man/man1/postmulti.1 +++ b/postfix/man/man1/postmulti.1 @@ -432,3 +432,5 @@ Wietse Venema Google, Inc. 111 8th Avenue New York, NY 10011, USA + +Wietse Venema diff --git a/postfix/man/man1/postsuper.1 b/postfix/man/man1/postsuper.1 index 885330f1d..5342fdb5b 100644 --- a/postfix/man/man1/postsuper.1 +++ b/postfix/man/man1/postsuper.1 @@ -46,7 +46,7 @@ from standard input. For example, to delete all mail with exactly one recipient \fBuser@example.com\fR: .sp .nf -postqueue \-j | jq -r ' +postqueue \-j | jq \-r ' # See JSON OBJECT FORMAT section in the postqueue(1) manpage select(.recipients[0].address == "user@example.com") | select(.recipients[1].address == null) @@ -54,7 +54,7 @@ postqueue \-j | jq -r ' ' | postsuper \-d \- .fi .sp -(note the "jq -r" option), or the historical form: +(note the "jq \-r" option), or the historical form: .sp .nf mailq | tail \-n +2 | grep \-v '^ *(' | awk 'BEGIN { RS = "" } @@ -302,7 +302,7 @@ the hash_queue_names parameter. The names of queue directories that are split across multiple subdirectory levels. .IP "\fBimport_environment (see 'postconf -d' output)\fR" -The list of environment parameters that a privileged Postfix +The list of environment variables that a privileged Postfix process will import from a non\-Postfix parent process, or name=value environment overrides. .IP "\fBqueue_directory (see 'postconf -d' output)\fR" @@ -341,3 +341,5 @@ Wietse Venema Google, Inc. 111 8th Avenue New York, NY 10011, USA + +Wietse Venema diff --git a/postfix/man/man1/sendmail.1 b/postfix/man/man1/sendmail.1 index 22affe637..547024f41 100644 --- a/postfix/man/man1/sendmail.1 +++ b/postfix/man/man1/sendmail.1 @@ -440,9 +440,10 @@ daemon processes. .IP "\fBqueue_directory (see 'postconf -d' output)\fR" The location of the Postfix top\-level queue directory. .IP "\fBremote_header_rewrite_domain (empty)\fR" -Don't rewrite message headers from remote clients at all when -this parameter is empty; otherwise, rewrite message headers and -append the specified domain name to incomplete addresses. +Rewrite or add message headers in mail from remote clients if +the remote_header_rewrite_domain parameter value is non\-empty, +updating incomplete addresses with the domain specified in the +remote_header_rewrite_domain parameter, and adding missing headers. .IP "\fBsyslog_facility (mail)\fR" The syslog facility of Postfix logging. .IP "\fBsyslog_name (see 'postconf -d' output)\fR" @@ -510,3 +511,5 @@ Wietse Venema Google, Inc. 111 8th Avenue New York, NY 10011, USA + +Wietse Venema diff --git a/postfix/man/man8/proxymap.8 b/postfix/man/man8/proxymap.8 index e734a2bca..1edc50989 100644 --- a/postfix/man/man8/proxymap.8 +++ b/postfix/man/man8/proxymap.8 @@ -241,3 +241,5 @@ Wietse Venema Google, Inc. 111 8th Avenue New York, NY 10011, USA + +Wietse Venema diff --git a/postfix/proto/stop.double-history b/postfix/proto/stop.double-history index 602285f0e..9d24dfe8f 100644 --- a/postfix/proto/stop.double-history +++ b/postfix/proto/stop.double-history @@ -38,3 +38,9 @@ proto proto SASL_README html proto SQLITE_README html util net_mask_top hc smtpd smtpd c smtpd smtpd_peer c util inet_prefix_top hc smtpd smtpd c smtpd smtpd_peer c File smtp smtp h + src master master_ent c src milter milter8 c src milter milter c + src oqmgr qmgr_message c src postfix postfix c + src postmulti postmulti c src postscreen postscreen_dnsbl c + src postsuper postsuper c src proxymap proxymap c + src postsuper postsuper c src proxymap proxymap c + src qmgr qmgr_message c src sendmail sendmail c diff --git a/postfix/proto/stop.spell-cc b/postfix/proto/stop.spell-cc index c642c7a32..3da669025 100644 --- a/postfix/proto/stop.spell-cc +++ b/postfix/proto/stop.spell-cc @@ -1800,3 +1800,4 @@ Stringify bitcount bytecount ipproto +cw diff --git a/postfix/src/cleanup/cleanup_init.c b/postfix/src/cleanup/cleanup_init.c index 8c43a0212..f3b2f79d4 100644 --- a/postfix/src/cleanup/cleanup_init.c +++ b/postfix/src/cleanup/cleanup_init.c @@ -77,6 +77,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -381,7 +383,8 @@ void cleanup_pre_jail(char *unused_name, char **unused_argv) name_mask(VAR_CANON_CLASSES, rcpt_canon_class_table, var_rcpt_canon_classes); if (*var_masq_domains) - cleanup_masq_domains = argv_split(var_masq_domains, CHARS_COMMA_SP); + cleanup_masq_domains = + argv_split_cw(var_masq_domains, CHARS_COMMA_SP, VAR_MASQ_DOMAINS); if (*var_header_checks) cleanup_header_checks = maps_create(VAR_HEADER_CHECKS, var_header_checks, DICT_FLAG_LOCK); diff --git a/postfix/src/global/attr_override.c b/postfix/src/global/attr_override.c index bff295454..4d51e41cf 100644 --- a/postfix/src/global/attr_override.c +++ b/postfix/src/global/attr_override.c @@ -6,7 +6,8 @@ /* SYNOPSIS /* #include /* -/* void attr_override(bp, delimiters, parens, ... CA_ATTR_OVER_END); +/* void attr_override(blame, bp, delimiters, parens, ..., +/* CA_ATTR_OVER_END) /* char *bp; /* const char *delimiters; /* const char *parens; @@ -22,6 +23,8 @@ /* fall-back policies, etc.). /* /* Arguments: +/* .IP blame +/* Context for error messages. /* .IP bp /* Pointer to input string. The input is modified. /* .IP "delimiters, parens" @@ -63,6 +66,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* @@ -88,7 +93,7 @@ /* attr_override - apply settings from list of attribute=value pairs */ -void attr_override(char *cp, const char *sep, const char *parens,...) +void attr_override(const char *blame, char *cp, const char *sep, const char *parens,...) { static const char myname[] = "attr_override"; va_list ap; @@ -146,10 +151,16 @@ void attr_override(char *cp, const char *sep, const char *parens,...) */ /* { name = value } */ if (*nameval == parens[0] - && (err = extpar(&nameval, parens, EXTPAR_FLAG_NONE)) != 0) + && (err = extpar(&nameval, parens, EXTPAR_FLAG_STRIP)) != 0) msg_fatal("%s in \"%s\"", err, nameval); + if (*nameval == '#') + msg_fatal("%s: #comment after other text is not allowed: \"...%s...\"", + blame, nameval); if ((err = split_nameval(nameval, &key, &value)) != 0) - msg_fatal("malformed option: %s: \"...%s...\"", err, nameval); + msg_fatal("%s: malformed option: %s: \"...%s...\"", blame, err, nameval); + if (*value == '#') + msg_fatal("%s: #comment after other text is not allowed: \"...%s %s\"", + blame, key, value); /* * Look up the name and apply the value. diff --git a/postfix/src/global/attr_override.h b/postfix/src/global/attr_override.h index 9f061620b..1b40c0c31 100644 --- a/postfix/src/global/attr_override.h +++ b/postfix/src/global/attr_override.h @@ -16,7 +16,7 @@ */ #include -extern void attr_override(char *, const char *, const char *,...); +extern void attr_override(const char *, char *, const char *, const char *,...); typedef struct { const char *name; @@ -65,6 +65,8 @@ CHECK_CPTR_HELPER_DCL(ATTR_OVER, ATTR_OVER_INT); /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ #endif diff --git a/postfix/src/global/config_known_tcp_ports.c b/postfix/src/global/config_known_tcp_ports.c index 563bbd356..31f719f31 100644 --- a/postfix/src/global/config_known_tcp_ports.c +++ b/postfix/src/global/config_known_tcp_ports.c @@ -29,6 +29,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -64,7 +66,7 @@ void config_known_tcp_ports(const char *source, const char *settings) * The settings is in the form of associations separated by comma. Split * it into separate associations. */ - associations = argv_split(settings, ","); + associations = argv_split(settings, ","); /* blame later */ if (associations->argc == 0) { argv_free(associations); return; @@ -79,7 +81,7 @@ void config_known_tcp_ports(const char *source, const char *settings) for (cpp = associations->argv; *cpp != 0; cpp++) { char *temp = concatenate(" ", *cpp, " ", (char *) 0); - association = argv_split_at(temp, '='); + association = argv_split_at(temp, '='); /* blame later */ myfree(temp); if (association->argc == 0) { @@ -97,6 +99,8 @@ void config_known_tcp_ports(const char *source, const char *settings) bp = association->argv[association->argc - 1]; if ((rhs = mystrtok(&bp, CHARS_SPACE)) == 0) { err = "missing port value after \"=\""; + } else if (*rhs == '#') { + err = "#comment after other text is not allowed"; } else if (mystrtok(&bp, CHARS_SPACE) != 0) { err = "whitespace in port number"; } else { @@ -106,6 +110,8 @@ void config_known_tcp_ports(const char *source, const char *settings) bp = association->argv[n]; if ((lhs = mystrtok(&bp, CHARS_SPACE)) == 0) { new_err = "missing service name before \"=\""; + } else if (*lhs == '#') { + err = "#comment after other text is not allowed"; } else if (mystrtok(&bp, CHARS_SPACE) != 0) { new_err = "whitespace in service name"; } else { diff --git a/postfix/src/global/dict_ldap.c b/postfix/src/global/dict_ldap.c index a4a4c2675..fb9845b49 100644 --- a/postfix/src/global/dict_ldap.c +++ b/postfix/src/global/dict_ldap.c @@ -175,6 +175,8 @@ /* Institute of Mathematics of the Romanian Academy /* P.O. BOX 1-764 /* RO-014700 Bucharest, ROMANIA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -1016,7 +1018,7 @@ static int attrdesc_subtype(const char *a1, const char *a2) /* url_attrs - attributes we want from LDAP URL */ -static char **url_attrs(DICT_LDAP *dict_ldap, LDAPURLDesc * url) +static char **url_attrs(DICT_LDAP *dict_ldap, LDAPURLDesc *url) { static ARGV *attrs; char **a1; @@ -1689,7 +1691,7 @@ DICT *dict_ldap_open(const char *ldapsource, int open_flags, int dict_flags) url_list = vstring_alloc(32); s = server_host; - while ((h = mystrtok(&s, CHARS_COMMA_SP)) != NULL) { + while ((h = mystrtok_cw(&s, CHARS_COMMA_SP, ldapsource)) != NULL) { #if defined(LDAP_API_FEATURE_X_OPENLDAP) /* @@ -1813,14 +1815,16 @@ DICT *dict_ldap_open(const char *ldapsource, int open_flags, int dict_flags) /* Order matters, first the terminal attributes: */ attr = cfg_get_str(dict_ldap->parser, "terminal_result_attribute", "", 0, 0); - dict_ldap->result_attributes = argv_split(attr, CHARS_COMMA_SP); + dict_ldap->result_attributes = argv_split_cw(attr, CHARS_COMMA_SP, + ldapsource); dict_ldap->num_terminal = dict_ldap->result_attributes->argc; myfree(attr); /* Order matters, next the leaf-only attributes: */ attr = cfg_get_str(dict_ldap->parser, "leaf_result_attribute", "", 0, 0); if (*attr) - argv_split_append(dict_ldap->result_attributes, attr, CHARS_COMMA_SP); + argv_split_append_cw(dict_ldap->result_attributes, attr, + CHARS_COMMA_SP, ldapsource); dict_ldap->num_leaf = dict_ldap->result_attributes->argc - dict_ldap->num_terminal; myfree(attr); @@ -1828,14 +1832,16 @@ DICT *dict_ldap_open(const char *ldapsource, int open_flags, int dict_flags) /* Order matters, next the regular attributes: */ attr = cfg_get_str(dict_ldap->parser, "result_attribute", "maildrop", 0, 0); if (*attr) - argv_split_append(dict_ldap->result_attributes, attr, CHARS_COMMA_SP); + argv_split_append_cw(dict_ldap->result_attributes, attr, + CHARS_COMMA_SP, ldapsource); dict_ldap->num_attributes = dict_ldap->result_attributes->argc; myfree(attr); /* Order matters, finally the special attributes: */ attr = cfg_get_str(dict_ldap->parser, "special_result_attribute", "", 0, 0); if (*attr) - argv_split_append(dict_ldap->result_attributes, attr, CHARS_COMMA_SP); + argv_split_append_cw(dict_ldap->result_attributes, attr, + CHARS_COMMA_SP, ldapsource); myfree(attr); /* diff --git a/postfix/src/global/dict_mysql.c b/postfix/src/global/dict_mysql.c index d90bc090d..e8b6bb86e 100644 --- a/postfix/src/global/dict_mysql.c +++ b/postfix/src/global/dict_mysql.c @@ -153,6 +153,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -790,7 +792,8 @@ static void mysql_parse_config(DICT_MYSQL *dict_mysql, const char *mysqlcf) hosts = cfg_get_str(p, "hosts", "", 0, 0); - dict_mysql->hosts = argv_split(hosts, CHARS_COMMA_SP); + dict_mysql->hosts = argv_split_cw(hosts, CHARS_COMMA_SP, + dict_mysql->dict.name); if (dict_mysql->hosts->argc == 0) { argv_add(dict_mysql->hosts, "localhost", ARGV_END); argv_terminate(dict_mysql->hosts); diff --git a/postfix/src/global/dict_pgsql.c b/postfix/src/global/dict_pgsql.c index f44a29ad0..c33697d30 100644 --- a/postfix/src/global/dict_pgsql.c +++ b/postfix/src/global/dict_pgsql.c @@ -135,6 +135,8 @@ /* Joshua Marcus /* IC Group, Inc. /* josh@icgroup.com +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -754,7 +756,8 @@ static void pgsql_parse_config(DICT_PGSQL *dict_pgsql, const char *pgsqlcf) hosts = cfg_get_str(p, "hosts", "", 0, 0); - dict_pgsql->hosts = argv_split(hosts, CHARS_COMMA_SP); + dict_pgsql->hosts = argv_split_cw(hosts, CHARS_COMMA_SP, + dict_pgsql->dict.name); if (dict_pgsql->hosts->argc == 0) { argv_add(dict_pgsql->hosts, "localhost", ARGV_END); argv_terminate(dict_pgsql->hosts); diff --git a/postfix/src/global/dynamicmaps.c b/postfix/src/global/dynamicmaps.c index 0b66ab9f8..14399e0e7 100644 --- a/postfix/src/global/dynamicmaps.c +++ b/postfix/src/global/dynamicmaps.c @@ -69,6 +69,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -251,7 +253,7 @@ static void dymap_read_conf(const char *path, const char *path_base) linenum++; if (*cp == '#' || *cp == '\0') continue; - argv = argv_split(cp, " \t"); + argv = argv_split_cw(cp, " \t", path); if (argv->argc != 3 && argv->argc != 4) msg_fatal("%s, line %d: Expected \"dict-type .so-name dict" "-function [mkmap-function]\"", path, linenum); diff --git a/postfix/src/global/header_opts.c b/postfix/src/global/header_opts.c index c0c4d5ceb..f0b54ac84 100644 --- a/postfix/src/global/header_opts.c +++ b/postfix/src/global/header_opts.c @@ -26,6 +26,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -135,7 +137,8 @@ static void header_drop_init(void) * * Thus, it is unlikely that all header flags will become configurable. */ - hdr_drop_list = argv_split(var_drop_hdrs, CHARS_COMMA_SP); + hdr_drop_list = argv_split_cw(var_drop_hdrs, CHARS_COMMA_SP, + VAR_DROP_HDRS); for (cpp = hdr_drop_list->argv; *cpp; cpp++) { lowercase(*cpp); if ((ht = htable_locate(header_hash, *cpp)) == 0) { diff --git a/postfix/src/global/login_sender_match.c b/postfix/src/global/login_sender_match.c index e263762ef..4fee9656b 100644 --- a/postfix/src/global/login_sender_match.c +++ b/postfix/src/global/login_sender_match.c @@ -79,6 +79,8 @@ r* The lookup table(s) with (login name, sender patterns) entries. /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -201,7 +203,8 @@ int login_sender_match(LOGIN_SENDER_MATCH *lsm, const char *login_name, */ cp = saved_sender_patterns = mystrdup(sender_patterns); while (found_or_error == LSM_STAT_NOTFOUND - && (sender_pattern = mystrtokdq(&cp, CHARS_COMMA_SP)) != 0) { + && (sender_pattern = mystrtokdq_cw(&cp, CHARS_COMMA_SP, + lsm->maps->title)) != 0) { /* Special pattern: @domain. */ if (*sender_pattern == '@') { if ((at_sender_domain = strrchr(sender_addr, '@')) != 0 diff --git a/postfix/src/global/mail_conf.c b/postfix/src/global/mail_conf.c index cd79d35dd..9033c0d00 100644 --- a/postfix/src/global/mail_conf.c +++ b/postfix/src/global/mail_conf.c @@ -104,6 +104,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -131,7 +133,7 @@ /* mail_conf_checkdir - authorize non-default directory */ -void mail_conf_checkdir(const char *config_dir) +void mail_conf_checkdir(const char *config_dir) { VSTRING *buf; VSTREAM *fp; @@ -155,7 +157,8 @@ void mail_conf_checkdir(const char *config_dir) if (split_nameval(vstring_str(buf), &name, &value) == 0 && (strcmp(name, VAR_CONFIG_DIRS) == 0 || strcmp(name, VAR_MULTI_CONF_DIRS) == 0)) { - while (found == 0 && (cp = mystrtok(&value, CHARS_COMMA_SP)) != 0) + while (found == 0 + && (cp = mystrtok_cw(&value, CHARS_COMMA_SP, path)) != 0) if (strcmp(cp, config_dir) == 0) found = 1; } diff --git a/postfix/src/global/mail_parm_split.c b/postfix/src/global/mail_parm_split.c index cf721d80f..ff85dce8b 100644 --- a/postfix/src/global/mail_parm_split.c +++ b/postfix/src/global/mail_parm_split.c @@ -41,6 +41,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -76,7 +78,7 @@ ARGV *mail_parm_split(const char *name, const char *value) * error. In this case, mystrtokq() detects no error, extpar() signals * the error to its caller, and this function handles the error. */ - while ((arg = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) { + while ((arg = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, name)) != 0) { if (*arg == CHARS_BRACE[0] && (err = extpar(&arg, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0) { #ifndef TEST diff --git a/postfix/src/global/mail_queue.c b/postfix/src/global/mail_queue.c index f73d1f1e3..6ea4dd46f 100644 --- a/postfix/src/global/mail_queue.c +++ b/postfix/src/global/mail_queue.c @@ -99,6 +99,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -171,7 +173,8 @@ const char *mail_queue_dir(VSTRING *buf, const char *queue_name, } if (hash_buf == 0) { hash_buf = vstring_alloc(100); - hash_queue_names = argv_split(var_hash_queue_names, CHARS_COMMA_SP); + hash_queue_names = argv_split_cw(var_hash_queue_names, CHARS_COMMA_SP, + VAR_HASH_QUEUE_NAMES); } /* diff --git a/postfix/src/global/maillog_client.c b/postfix/src/global/maillog_client.c index 7f79a1f6d..d5c10c42e 100644 --- a/postfix/src/global/maillog_client.c +++ b/postfix/src/global/maillog_client.c @@ -75,6 +75,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -209,8 +211,9 @@ void maillog_client_init(const char *progname, int flags) char *service_path; if (var_maillog_file && *var_maillog_file) { - ARGV *good_prefixes = argv_split(var_maillog_file_pfxs, - CHARS_COMMA_SP); + ARGV *good_prefixes = argv_split_cw(var_maillog_file_pfxs, + CHARS_COMMA_SP, + VAR_MAILLOG_FILE_PFXS); char **cpp; for (cpp = good_prefixes->argv; /* see below */ ; cpp++) { diff --git a/postfix/src/global/map_search.c b/postfix/src/global/map_search.c index b10f7d516..b2cfe4f10 100644 --- a/postfix/src/global/map_search.c +++ b/postfix/src/global/map_search.c @@ -63,6 +63,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -158,8 +160,8 @@ const MAP_SEARCH *map_search_create(const char *map_spec) if ((heap_err = extpar(&bp, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0) { msg_warn("malformed map specification: '%s'", heap_err); MAP_SEARCH_CREATE_RETURN(0); - } else if ((map_type_name = mystrtokq(&bp, CHARS_COMMA_SP, - CHARS_BRACE)) == 0) { + } else if ((map_type_name = mystrtokq_cw(&bp, CHARS_COMMA_SP, + CHARS_BRACE, map_spec)) == 0) { msg_warn("empty map specification: '%s'", map_spec); MAP_SEARCH_CREATE_RETURN(0); } @@ -181,7 +183,8 @@ const MAP_SEARCH *map_search_create(const char *map_spec) * with the same attribute name. */ if (bp != 0) { - while ((attr_name_val = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) { + while ((attr_name_val = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, + map_spec)) != 0) { if (*attr_name_val == CHARS_BRACE[0]) { if ((heap_err = extpar(&attr_name_val, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0) { @@ -208,7 +211,8 @@ const MAP_SEARCH *map_search_create(const char *map_spec) */ if (attr_name != 0) { search_order = vstring_alloc(10); - while ((atom = mystrtok(&attr_value, CHARS_COMMA_SP)) != 0) { + while ((atom = mystrtok_cw(&attr_value, CHARS_COMMA_SP, + map_spec)) != 0) { if ((code = name_code(map_search_actions, NAME_CODE_FLAG_NONE, atom)) == MAP_SEARCH_CODE_UNKNOWN) { msg_warn("unknown search type '%s' in '%s'", atom, map_spec); @@ -310,6 +314,9 @@ int main(int argc, char **argv) {"{type:name {search_order=one, two, bad}}", 0, 0, 0}, {"{inline:{a=b} {search_order=one, two}}", 1, "inline:{a=b}", "\01\02"}, {"{inline:{a=b, c=d} {search_order=one, two}}", 1, "inline:{a=b, c=d}", "\01\02"}, + {"#after text", 0, 0, 0}, + {"{type:name, #after text}", 1, "type:name", 0}, + {"{type:name {search_order=one, two, #after text}}", 1, "type:name", "\01\02"}, {0}, }; TEST_CASE *test_case; diff --git a/postfix/src/global/map_search.ref b/postfix/src/global/map_search.ref index a296e4e4a..12655cc69 100644 --- a/postfix/src/global/map_search.ref +++ b/postfix/src/global/map_search.ref @@ -20,3 +20,10 @@ unknown: test case 10: '{type:name {search_order=one, two, bad}}' unknown: warning: unknown search type 'bad' in '{type:name {search_order=one, two, bad}}' unknown: test case 11: '{inline:{a=b} {search_order=one, two}}' unknown: test case 12: '{inline:{a=b, c=d} {search_order=one, two}}' +unknown: test case 13: '#after text' +unknown: warning: malformed map specification: '#after text' +unknown: warning: expected maptype:mapname instead of '#after text' +unknown: test case 14: '{type:name, #after text}' +unknown: warning: {type:name, #after text}: #comment after other text is not allowed: #after text +unknown: test case 15: '{type:name {search_order=one, two, #after text}}' +unknown: warning: {type:name {search_order=one, two, #after text}}: #comment after other text is not allowed: #after text diff --git a/postfix/src/global/maps.c b/postfix/src/global/maps.c index 790396bba..7a86271ee 100644 --- a/postfix/src/global/maps.c +++ b/postfix/src/global/maps.c @@ -100,6 +100,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -153,7 +155,7 @@ MAPS *maps_create(const char *title, const char *map_names, int dict_flags) #define OPEN_FLAGS O_RDONLY - while ((map_type_name = mystrtokq(&bufp, sep, parens)) != 0) { + while ((map_type_name = mystrtokq_cw(&bufp, sep, parens, title)) != 0) { vstring_sprintf(map_type_name_flags, "%s(%o,%s)", map_type_name, OPEN_FLAGS, dict_flags_str(dict_flags)); diff --git a/postfix/src/global/own_inet_addr.c b/postfix/src/global/own_inet_addr.c index d164a20b2..1b34d4de0 100644 --- a/postfix/src/global/own_inet_addr.c +++ b/postfix/src/global/own_inet_addr.c @@ -42,6 +42,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -143,7 +145,7 @@ static void own_inet_addr_init(INET_ADDR_LIST *addr_list, */ else { bufp = hosts = mystrdup(var_inet_interfaces); - while ((host = mystrtok(&bufp, sep)) != 0) + while ((host = mystrtok_cw(&bufp, sep, VAR_INET_INTERFACES)) != 0) if (inet_addr_host(addr_list, host) == 0) msg_fatal("config variable %s: host not found: %s", VAR_INET_INTERFACES, host); @@ -191,7 +193,7 @@ static void own_inet_addr_init(INET_ADDR_LIST *addr_list, /* own_inet_addr - is this my own internet address */ -int own_inet_addr(struct sockaddr * addr) +int own_inet_addr(struct sockaddr *addr) { int i; @@ -239,7 +241,7 @@ static void proxy_inet_addr_init(INET_ADDR_LIST *addr_list) */ inet_addr_list_init(addr_list); bufp = hosts = mystrdup(var_proxy_interfaces); - while ((host = mystrtok(&bufp, sep)) != 0) + while ((host = mystrtok_cw(&bufp, sep, VAR_PROXY_INTERFACES)) != 0) if (inet_addr_host(addr_list, host) == 0) msg_fatal("config variable %s: host not found: %s", VAR_PROXY_INTERFACES, host); @@ -253,7 +255,7 @@ static void proxy_inet_addr_init(INET_ADDR_LIST *addr_list) /* proxy_inet_addr - is this my proxy internet address */ -int proxy_inet_addr(struct sockaddr * addr) +int proxy_inet_addr(struct sockaddr *addr) { int i; diff --git a/postfix/src/global/server_acl.c b/postfix/src/global/server_acl.c index 5385a5a1f..21a6b752c 100644 --- a/postfix/src/global/server_acl.c +++ b/postfix/src/global/server_acl.c @@ -64,6 +64,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -112,7 +114,7 @@ void server_acl_pre_jail_init(const char *mynetworks, const char *origin) if (warn_compat_break_mynetworks_style) server_acl_mynetworks_host = addr_match_list_init(origin, MATCH_FLAG_RETURN - | match_parent_style(origin), mynetworks_host()); + | match_parent_style(origin), mynetworks_host()); } /* server_acl_parse - parse access list */ @@ -132,7 +134,7 @@ SERVER_ACL *server_acl_parse(const char *extern_acl, const char *origin) * chroot jail, while access lists are evaluated after entering the * chroot jail. */ - while ((acl = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) { + while ((acl = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, origin)) != 0) { if (strchr(acl, ':') != 0) { if (strchr(origin, ':') != 0) { msg_warn("table %s: lookup result \"%s\" is not allowed" @@ -240,7 +242,7 @@ int server_acl_eval(const char *client_addr, SERVER_ACL * intern_acl, #include #include #include - + char *var_server_acl = ""; #define UPDATE_VAR(s,v) do { if (*(s)) myfree(s); (s) = mystrdup(v); } while (0) diff --git a/postfix/src/local/dotforward.c b/postfix/src/local/dotforward.c index 3ce2cfca9..226843c24 100644 --- a/postfix/src/local/dotforward.c +++ b/postfix/src/local/dotforward.c @@ -43,6 +43,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -194,7 +196,7 @@ int deliver_dotforward(LOCAL_STATE state, USER_ATTR usr_attr, int *statusp) next = saved_forward_path; lookup_status = -1; - while ((lhs = mystrtok(&next, CHARS_COMMA_SP)) != 0) { + while ((lhs = mystrtok_cw(&next, CHARS_COMMA_SP, VAR_FORWARD_PATH)) != 0) { expand_status = local_expand(path, lhs, &state, &usr_attr, var_fwd_exp_filter); if ((expand_status & (MAC_PARSE_ERROR | MAC_PARSE_UNDEF)) == 0) { diff --git a/postfix/src/master/master_ent.c b/postfix/src/master/master_ent.c index 5edc30872..86a9ebcad 100644 --- a/postfix/src/master/master_ent.c +++ b/postfix/src/master/master_ent.c @@ -62,6 +62,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System libraries. */ @@ -213,7 +215,7 @@ static char *get_str_ent(char **bufp, char *name, char *def_val) { char *value; - if ((value = mystrtok(bufp, master_blanks)) == 0) + if ((value = mystrtok_cw(bufp, master_blanks, master_conf_context())) == 0) fatal_with_context("missing \"%s\" field", name); if (strcmp(value, "-") == 0) { if (def_val == 0) @@ -576,6 +578,11 @@ MASTER_SERV *get_master_ent() argv_add(serv->args, "-s", vstring_str(vstring_sprintf(junk, "%d", serv->listen_fd_count)), (char *) 0); + + /* + * The remaining arguments may have application-specific syntax. Do not + * complain about words that start with a '#'. + */ while ((cp = mystrtokq(&bufp, master_blanks, CHARS_BRACE)) != 0) { if (*cp == CHARS_BRACE[0] && (err = extpar(&cp, CHARS_BRACE, EXTPAR_FLAG_STRIP)) != 0) diff --git a/postfix/src/milter/milter.c b/postfix/src/milter/milter.c index dfd5e1c48..ec9dcb794 100644 --- a/postfix/src/milter/milter.c +++ b/postfix/src/milter/milter.c @@ -235,6 +235,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -280,7 +282,8 @@ HTABLE *milter_macro_defaults_create(const char *macro_defaults) VSTRING *canon_buf = 0; char *nameval; - while ((nameval = mystrtokq(&cp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) { + while ((nameval = mystrtokq_cw(&cp, CHARS_COMMA_SP, CHARS_BRACE, + VAR_MILT_MACRO_DEFLTS)) != 0) { const char *err; char *name; char *value; @@ -335,7 +338,8 @@ static ARGV *milter_macro_lookup(MILTERS *milters, const char *macro_names) const char *name; const char *cname; - while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) { + /* XXX Which parameter to blame? */ + while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, "milter_macros")) != 0) { if (msg_verbose) msg_info("%s: \"%s\"", myname, name); if (*name != '{') /* } */ @@ -684,10 +688,13 @@ MILTERS *milter_new(const char *names, char *op; char *err; + /* XXX Which parameter to blame? */ + char *blame = "milters"; + /* * Instantiate Milters, allowing for per-Milter overrides. */ - while ((name = mystrtokq(&cp, sep, parens)) != 0) { + while ((name = mystrtokq_cw(&cp, sep, parens, blame)) != 0) { my_conn_timeout = conn_timeout; my_cmd_timeout = cmd_timeout; my_msg_timeout = msg_timeout; @@ -697,9 +704,9 @@ MILTERS *milter_new(const char *names, op = name; if ((err = extpar(&op, parens, EXTPAR_FLAG_NONE)) != 0) msg_fatal("milter service syntax error: %s", err); - if ((name = mystrtok(&op, sep)) == 0) + if ((name = mystrtok_cw(&op, sep, blame)) == 0) msg_fatal("empty milter definition: \"%s\"", names); - attr_override(op, sep, parens, + attr_override(blame, op, sep, parens, CA_ATTR_OVER_STR_TABLE(str_table), CA_ATTR_OVER_TIME_TABLE(time_table), CA_ATTR_OVER_END); diff --git a/postfix/src/milter/milter8.c b/postfix/src/milter/milter8.c index 6c9a1eec4..953f44459 100644 --- a/postfix/src/milter/milter8.c +++ b/postfix/src/milter/milter8.c @@ -56,6 +56,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -1157,7 +1159,7 @@ static const char *milter8_event(MILTER8 *milter, int event, if (edit_resp == 0) edit_resp = parent->repl_body(parent->chg_context, MILTER_BODY_END, - /* unused*/ 0, + /* unused */ 0, (VSTRING *) 0); body_edit_lockout = 1; vstring_free(body_line_buf); @@ -1553,7 +1555,7 @@ static const char *milter8_event(MILTER8 *milter, int event, body_line_buf = vstring_alloc(var_line_limit); edit_resp = parent->repl_body(parent->chg_context, MILTER_BODY_START, - /* unused */ 0, + /* unused */ 0, (VSTRING *) 0); } /* Extract lines from the on-the-wire CRLF format. */ @@ -1671,7 +1673,7 @@ static void milter8_connect(MILTER8 *milter) * don't want to take the risk that a future version will be more picky. */ cp = saved_version = mystrdup(milter->protocol); - while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) { + while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, VAR_MILT_PROTOCOL)) != 0) { int mask; int vers; diff --git a/postfix/src/oqmgr/qmgr_message.c b/postfix/src/oqmgr/qmgr_message.c index b885264a2..277417f5e 100644 --- a/postfix/src/oqmgr/qmgr_message.c +++ b/postfix/src/oqmgr/qmgr_message.c @@ -94,6 +94,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -1148,7 +1150,9 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) */ if (*var_defer_xports && (message->qflags & QMGR_FLUSH_DFXP) == 0) { if (defer_xport_argv == 0) - defer_xport_argv = argv_split(var_defer_xports, CHARS_COMMA_SP); + defer_xport_argv = argv_split_cw(var_defer_xports, + CHARS_COMMA_SP, + VAR_DEFER_XPORTS); for (cpp = defer_xport_argv->argv; *cpp; cpp++) if (strcmp(*cpp, STR(reply.transport)) == 0) break; diff --git a/postfix/src/postfix/postfix.c b/postfix/src/postfix/postfix.c index c7f8b40ad..2ab1b9550 100644 --- a/postfix/src/postfix/postfix.c +++ b/postfix/src/postfix/postfix.c @@ -37,7 +37,7 @@ /* when running as PID 1. /* This command requires that multi-instance support is /* disabled (i.e. the multi_instance_directories parameter -/* value must be empty). +/* value must be empty). /* /* When running Postfix inside a container, see MAILLOG_README /* for logging to stdout. Postfix logs to syslog by default, @@ -412,6 +412,8 @@ /* Jun-ichiro 'itojun' Hagino, KAME project, Japan /* The Linux PLD project /* Dean Strik, Eindhoven University, The Netherlands +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -634,7 +636,8 @@ int main(int argc, char **argv) * Run the management script. */ if (force_single_instance - || argv_split(var_multi_conf_dirs, CHARS_COMMA_SP)->argc == 0) { + || argv_split_cw(var_multi_conf_dirs, CHARS_COMMA_SP, + VAR_MULTI_CONF_DIRS)->argc == 0) { script = concatenate(var_daemon_dir, "/postfix-script", (char *) 0); if (optind < 1) msg_panic("bad optind value"); diff --git a/postfix/src/postmulti/postmulti.c b/postfix/src/postmulti/postmulti.c index 5adcd272c..e5bbe8e7a 100644 --- a/postfix/src/postmulti/postmulti.c +++ b/postfix/src/postmulti/postmulti.c @@ -404,6 +404,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -872,7 +874,8 @@ static void load_all_instances(void) * only comma characters. Count the actual number of elements, before we * decide that the list is empty. */ - secondary_names = argv_split(var_multi_conf_dirs, CHARS_COMMA_SP); + secondary_names = argv_split_cw(var_multi_conf_dirs, CHARS_COMMA_SP, + VAR_MULTI_CONF_DIRS); /* * First, the primary instance. This is synthesized out of thin air. @@ -1471,14 +1474,15 @@ static int run_user_command(INSTANCE *ip, int iter_cmd, int iter_flags, /* word_in_list - look up command in start, stop, or control list */ -static int word_in_list(char *cmdlist, const char *cmd) +static int word_in_list(char *cmdlist, const char *cmd, const char *blame) { char *saved; char *cp; char *elem; cp = saved = mystrdup(cmdlist); - while ((elem = mystrtok(&cp, CHARS_COMMA_SP)) != 0 && strcmp(elem, cmd) != 0) + while ((elem = mystrtok_cw(&cp, CHARS_COMMA_SP, blame)) != 0 + && strcmp(elem, cmd) != 0) /* void */ ; myfree(saved); return (elem != 0); @@ -1497,11 +1501,13 @@ static int iterate_postfix_command(int iter_cmd, int argc, char **argv, /* * Override the iterator controls. */ - if (word_in_list(var_multi_start_cmds, argv[0])) { + if (word_in_list(var_multi_start_cmds, argv[0], VAR_MULTI_START_CMDS)) { iter_flags = ITER_FLAG_CHECK_DISABLED; - } else if (word_in_list(var_multi_stop_cmds, argv[0])) { + } else if (word_in_list(var_multi_stop_cmds, argv[0], + VAR_MULTI_STOP_CMDS)) { iter_flags = ITER_FLAG_SKIP_DISABLED | ITER_FLAG_REVERSE; - } else if (word_in_list(var_multi_cntrl_cmds, argv[0])) { + } else if (word_in_list(var_multi_cntrl_cmds, argv[0], + VAR_MULTI_CNTRL_CMDS)) { iter_flags = ITER_FLAG_SKIP_DISABLED; } else { iter_flags = 0; diff --git a/postfix/src/postscreen/postscreen_dnsbl.c b/postfix/src/postscreen/postscreen_dnsbl.c index 7d9a5e94b..9cb3f0afc 100644 --- a/postfix/src/postscreen/postscreen_dnsbl.c +++ b/postfix/src/postscreen/postscreen_dnsbl.c @@ -58,6 +58,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -231,7 +233,7 @@ static void psc_dnsbl_add_site(const char *site) int weight; HTABLE_INFO *ht; char *parse_err; - const char *safe_dnsbl; + const char *safe_dnsbl; /* * Parse the required DNSBL domain name, the optional reply filter and @@ -584,7 +586,8 @@ int psc_dnsbl_request(const char *client_addr, void psc_dnsbl_init(void) { const char *myname = "psc_dnsbl_init"; - ARGV *dnsbl_site = argv_split(var_psc_dnsbl_sites, CHARS_COMMA_SP); + ARGV *dnsbl_site = argv_split_cw(var_psc_dnsbl_sites, CHARS_COMMA_SP, + VAR_PSC_DNSBL_SITES); char **cpp; /* diff --git a/postfix/src/postsuper/postsuper.c b/postfix/src/postsuper/postsuper.c index d3f2d5bcd..6884c3b4f 100644 --- a/postfix/src/postsuper/postsuper.c +++ b/postfix/src/postsuper/postsuper.c @@ -288,7 +288,7 @@ /* The names of queue directories that are split across multiple /* subdirectory levels. /* .IP "\fBimport_environment (see 'postconf -d' output)\fR" -/* The list of environment parameters that a privileged Postfix +/* The list of environment variables that a privileged Postfix /* process will import from a non-Postfix parent process, or name=value /* environment overrides. /* .IP "\fBqueue_directory (see 'postconf -d' output)\fR" @@ -321,6 +321,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -900,7 +902,9 @@ static int fix_queue_id(const char *actual_path, const char *actual_queue, static void super(const char **queues, int action) { - ARGV *hash_queue_names = argv_split(var_hash_queue_names, CHARS_COMMA_SP); + ARGV *hash_queue_names = argv_split_cw(var_hash_queue_names, + CHARS_COMMA_SP, + VAR_HASH_QUEUE_NAMES); VSTRING *actual_path = vstring_alloc(10); VSTRING *wanted_path = vstring_alloc(10); struct stat st; diff --git a/postfix/src/proxymap/proxymap.c b/postfix/src/proxymap/proxymap.c index abdcf3af7..63cbffa12 100644 --- a/postfix/src/proxymap/proxymap.c +++ b/postfix/src/proxymap/proxymap.c @@ -215,6 +215,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -685,13 +687,13 @@ DICT *dict_proxy_open(const char *map, int open_flags, int dict_flags) /* authorize_proxied_maps - recursively authorize maps */ -static void authorize_proxied_maps(char *bp) +static void authorize_proxied_maps(char *bp, const char *blame) { const char *sep = CHARS_COMMA_SP; const char *parens = CHARS_BRACE; char *type_name; - while ((type_name = mystrtokq(&bp, sep, parens)) != 0) { + while ((type_name = mystrtokq_cw(&bp, sep, parens, blame)) != 0) { char *nested_info; /* Maybe { maptype:mapname attr=value... } */ @@ -706,7 +708,7 @@ static void authorize_proxied_maps(char *bp) continue; } /* Don't try to second-guess the semantics of { }. */ - if ((type_name = mystrtokq(&type_name, sep, parens)) == 0) + if ((type_name = mystrtokq_cw(&type_name, sep, parens, blame)) == 0) continue; } /* Recurse into nested map (pipemap, unionmap). */ @@ -722,7 +724,7 @@ static void authorize_proxied_maps(char *bp) myfree(err); continue; } - authorize_proxied_maps(nested_info); + authorize_proxied_maps(nested_info, blame); continue; } if (strncmp(type_name, PROXY_COLON, PROXY_COLON_LEN)) @@ -770,7 +772,8 @@ static void post_jail_init(char *service_name, char **unused_argv) saved_filter = mystrdup(proxy_writer ? var_proxy_write_maps : var_proxy_read_maps); proxy_auth_maps = htable_create(13); - authorize_proxied_maps(saved_filter); + authorize_proxied_maps(saved_filter, proxy_writer ? VAR_PROXY_WRITE_MAPS : + VAR_PROXY_READ_MAPS); myfree(saved_filter); /* diff --git a/postfix/src/qmgr/qmgr_message.c b/postfix/src/qmgr/qmgr_message.c index 79143f3d3..623133dbc 100644 --- a/postfix/src/qmgr/qmgr_message.c +++ b/postfix/src/qmgr/qmgr_message.c @@ -102,6 +102,8 @@ /* Patrik Rak /* Modra 6 /* 155 00, Prague, Czech Republic +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -1207,7 +1209,9 @@ static void qmgr_message_resolve(QMGR_MESSAGE *message) */ if (*var_defer_xports && (message->qflags & QMGR_FLUSH_DFXP) == 0) { if (defer_xport_argv == 0) - defer_xport_argv = argv_split(var_defer_xports, CHARS_COMMA_SP); + defer_xport_argv = argv_split_cw(var_defer_xports, + CHARS_COMMA_SP, + VAR_DEFER_XPORTS); for (cpp = defer_xport_argv->argv; *cpp; cpp++) if (strcmp(*cpp, STR(reply.transport)) == 0) break; diff --git a/postfix/src/sendmail/sendmail.c b/postfix/src/sendmail/sendmail.c index 27b354345..fe402d523 100644 --- a/postfix/src/sendmail/sendmail.c +++ b/postfix/src/sendmail/sendmail.c @@ -412,9 +412,10 @@ /* .IP "\fBqueue_directory (see 'postconf -d' output)\fR" /* The location of the Postfix top-level queue directory. /* .IP "\fBremote_header_rewrite_domain (empty)\fR" -/* Don't rewrite message headers from remote clients at all when -/* this parameter is empty; otherwise, rewrite message headers and -/* append the specified domain name to incomplete addresses. +/* Rewrite or add message headers in mail from remote clients if +/* the remote_header_rewrite_domain parameter value is non-empty, +/* updating incomplete addresses with the domain specified in the +/* remote_header_rewrite_domain parameter, and adding missing headers. /* .IP "\fBsyslog_facility (mail)\fR" /* The syslog facility of Postfix logging. /* .IP "\fBsyslog_name (see 'postconf -d' output)\fR" @@ -472,6 +473,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -1482,7 +1485,8 @@ int main(int argc, char **argv) if (alias_map_from_args != 0) argv_add(ext_argv, alias_map_from_args, (char *) 0); else - argv_split_append(ext_argv, var_alias_db_map, CHARS_COMMA_SP); + argv_split_append_cw(ext_argv, var_alias_db_map, CHARS_COMMA_SP, + VAR_ALIAS_DB_MAP); argv_terminate(ext_argv); mail_run_replace(var_command_dir, ext_argv->argv); /* NOTREACHED */ diff --git a/postfix/src/smtp/smtp_connect.c b/postfix/src/smtp/smtp_connect.c index 68faca18e..8d2076ffb 100644 --- a/postfix/src/smtp/smtp_connect.c +++ b/postfix/src/smtp/smtp_connect.c @@ -56,6 +56,8 @@ /* Connection caching in cooperation with: /* Victor Duchovni /* Morgan Stanley +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -832,7 +834,8 @@ static void smtp_connect_inet(SMTP_STATE *state, const char *nexthop, if (sites->argc == 0) msg_panic("null destination: \"%s\"", nexthop); non_fallback_sites = sites->argc; - argv_split_append(sites, var_fallback_relay, CHARS_COMMA_SP); + argv_split_append_cw(sites, var_fallback_relay, CHARS_COMMA_SP, + VAR_SMTP_FALLBACK); /* * Don't give up after a hard host lookup error until we have tried the diff --git a/postfix/src/smtp/smtp_tls_policy.c b/postfix/src/smtp/smtp_tls_policy.c index 92a231df5..8db39cc36 100644 --- a/postfix/src/smtp/smtp_tls_policy.c +++ b/postfix/src/smtp/smtp_tls_policy.c @@ -80,6 +80,8 @@ /* New York, NY 10011, USA /* /* Viktor Dukhovni +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -250,7 +252,7 @@ static void tls_policy_lookup_one(SMTP_TLS_POLICY *tls, int *site_level, } saved_policy = policy = mystrdup(lookup); - if ((tok = mystrtok(&policy, CHARS_COMMA_SP)) == 0) { + if ((tok = mystrtok_cw(&policy, CHARS_COMMA_SP, tls_policy->title)) == 0) { msg_warn("%s: invalid empty policy", WHERE); INVALID_RETURN(tls->why, site_level); } @@ -265,7 +267,7 @@ static void tls_policy_lookup_one(SMTP_TLS_POLICY *tls, int *site_level, * Warn about ignored attributes when TLS is disabled. */ if (*site_level < TLS_LEV_MAY) { - while ((tok = mystrtok(&policy, CHARS_COMMA_SP)) != 0) + while ((tok = mystrtok_cw(&policy, CHARS_COMMA_SP, tls_policy->title)) != 0) msg_warn("%s: ignoring attribute \"%s\" with TLS disabled", WHERE, tok); FREE_RETURN; @@ -275,7 +277,7 @@ static void tls_policy_lookup_one(SMTP_TLS_POLICY *tls, int *site_level, * Errors in attributes may have security consequences, don't ignore * errors that can degrade security. */ - while ((tok = mystrtok(&policy, CHARS_COMMA_SP)) != 0) { + while ((tok = mystrtok_cw(&policy, CHARS_COMMA_SP, tls_policy->title)) != 0) { if ((err = split_nameval(tok, &name, &val)) != 0) { msg_warn("%s: malformed attribute/value pair \"%s\": %s", WHERE, tok, err); @@ -425,7 +427,7 @@ static void tls_policy_lookup(SMTP_TLS_POLICY *tls, int *site_level, /* load_tas - load one or more ta files */ -static int load_tas(TLS_DANE *dane, const char *files) +static int load_tas(TLS_DANE *dane, const char *files, const char *blame) { int ret = 0; char *save = mystrdup(files); @@ -433,7 +435,7 @@ static int load_tas(TLS_DANE *dane, const char *files) char *file; do { - if ((file = mystrtok(&buf, CHARS_COMMA_SP)) != 0) + if ((file = mystrtok_cw(&buf, CHARS_COMMA_SP, blame)) != 0) ret = tls_dane_load_trustfile(dane, file); } while (file && ret); @@ -633,14 +635,16 @@ static void *policy_create(const char *unused_key, void *context) case TLS_LEV_SECURE: if (tls->matchargv == 0) tls->matchargv = - argv_split(tls->level == TLS_LEV_VERIFY ? - var_smtp_tls_vfy_cmatch : var_smtp_tls_sec_cmatch, - CHARS_COMMA_SP ":"); + argv_split_cw(tls->level == TLS_LEV_VERIFY ? + var_smtp_tls_vfy_cmatch : var_smtp_tls_sec_cmatch, + CHARS_COMMA_SP ":", tls->level == TLS_LEV_VERIFY ? + VAR_SMTP_TLS_VFY_CMATCH : VAR_SMTP_TLS_SEC_CMATCH); if (*var_smtp_tls_tafile) { if (tls->dane == 0) tls->dane = tls_dane_alloc(); if (tls->dane->tlsa == 0 - && !load_tas(tls->dane, var_smtp_tls_tafile)) { + && !load_tas(tls->dane, var_smtp_tls_tafile, + VAR_SMTP_TLS_TAFILE)) { MARK_INVALID(tls->why, &tls->level); return ((void *) tls); } diff --git a/postfix/src/smtpd/smtpd_check.c b/postfix/src/smtpd/smtpd_check.c index b5ce4a94f..13e5828f4 100644 --- a/postfix/src/smtpd/smtpd_check.c +++ b/postfix/src/smtpd/smtpd_check.c @@ -174,6 +174,8 @@ /* Allgemeine Elektrotechnik /* Universitaetsplatz 3-4 /* D-03044 Cottbus, Germany +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -549,7 +551,7 @@ static const NAME_CODE search_actions[] = { /* policy_client_register - register policy service endpoint */ -static void policy_client_register(const char *name) +static void policy_client_register(const char *name, const char *pname) { static const char myname[] = "policy_client_register"; SMTPD_POLICY_CLNT *policy_client; @@ -590,9 +592,9 @@ static void policy_client_register(const char *name) cp = saved_name = mystrdup(name); if ((err = extpar(&cp, parens, EXTPAR_FLAG_NONE)) != 0) msg_fatal("policy service syntax error: %s", cp); - if ((policy_name = mystrtok(&cp, sep)) == 0) + if ((policy_name = mystrtok_cw(&cp, sep, pname)) == 0) msg_fatal("empty policy service: \"%s\"", name); - attr_override(cp, sep, parens, + attr_override(pname, cp, sep, parens, CA_ATTR_OVER_TIME_TABLE(time_table), CA_ATTR_OVER_INT_TABLE(int_table), CA_ATTR_OVER_STR_TABLE(str_table), @@ -651,7 +653,7 @@ static void command_map_register(const char *name) /* smtpd_check_parse - pre-parse restrictions */ -static ARGV *smtpd_check_parse(int flags, const char *checks) +static ARGV *smtpd_check_parse(int flags, const char *pname, const char *checks) { char *saved_checks = mystrdup(checks); ARGV *argv = argv_alloc(1); @@ -669,11 +671,12 @@ static ARGV *smtpd_check_parse(int flags, const char *checks) #define SMTPD_CHECK_PARSE_MAPS (1<<1) #define SMTPD_CHECK_PARSE_ALL (~0) - while ((name = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) { + while ((name = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, + pname)) != 0) { argv_add(argv, name, (char *) 0); if ((flags & SMTPD_CHECK_PARSE_POLICY) && last && strcasecmp(last, CHECK_POLICY_SERVICE) == 0) { - policy_client_register(name); + policy_client_register(name, pname); } else if ((flags & SMTPD_CHECK_PARSE_MAPS) && (*name == *CHARS_BRACE || strchr(name, ':') != 0)) { if ((map_search = map_search_create(name)) != 0) @@ -881,23 +884,32 @@ void smtpd_check_init(void) * before going to jail. */ client_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_CLIENT_CHECKS, var_client_checks); helo_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_HELO_CHECKS, var_helo_checks); mail_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_MAIL_CHECKS, var_mail_checks); relay_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_RELAY_CHECKS, var_relay_checks); if (warn_compat_break_relay_restrictions) fake_relay_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + "fake relay restrictions", FAKE_RELAY_CHECKS); rcpt_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_RCPT_CHECKS, var_rcpt_checks); etrn_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_ETRN_CHECKS, var_etrn_checks); data_restrctions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_DATA_CHECKS, var_data_checks); eod_restrictions = smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_EOD_CHECKS, var_eod_checks); /* @@ -906,12 +918,14 @@ void smtpd_check_init(void) smtpd_rest_classes = htable_create(1); if (*var_rest_classes) { cp = saved_classes = mystrdup(var_rest_classes); - while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) { + while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, + VAR_REST_CLASSES)) != 0) { if ((value = mail_conf_lookup_eval(name)) == 0 || *value == 0) msg_fatal("restriction class `%s' needs a definition", name); /* XXX This store operation should not be case-sensitive. */ htable_enter(smtpd_rest_classes, name, (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + VAR_REST_CLASSES, value)); } myfree(saved_classes); @@ -928,6 +942,7 @@ void smtpd_check_init(void) #endif htable_enter(smtpd_rest_classes, REJECT_SENDER_LOGIN_MISMATCH, (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + REJECT_SENDER_LOGIN_MISMATCH, REJECT_AUTH_SENDER_LOGIN_MISMATCH " " REJECT_UNAUTH_SENDER_LOGIN_MISMATCH)); @@ -947,6 +962,7 @@ void smtpd_check_init(void) * Local rewrite policy. */ local_rewrite_clients = smtpd_check_parse(SMTPD_CHECK_PARSE_MAPS, + VAR_LOC_RWR_CLIENTS, var_local_rwr_clients); /* @@ -2743,7 +2759,7 @@ static int check_table_result(SMTPD_STATE *state, const char *table, */ #define ADDROF(x) ((char *) &(x)) - restrictions = argv_splitq(value, CHARS_COMMA_SP, CHARS_BRACE); + restrictions = argv_splitq_cw(value, CHARS_COMMA_SP, CHARS_BRACE, table); memcpy(ADDROF(savebuf), ADDROF(smtpd_check_buf), sizeof(savebuf)); status = setjmp(smtpd_check_buf); if (status != 0) { @@ -3913,7 +3929,8 @@ static int reject_auth_sender_login_mismatch(SMTPD_STATE *state, const char *sen if ((owners = check_mail_addr_find(state, sender, smtpd_sender_login_maps, STR(reply->recipient), (char **) 0)) != 0) { cp = saved_owners = mystrdup(owners); - while ((name = mystrtok(&cp, CHARS_COMMA_SP)) != 0) { + while ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, + VAR_SMTPD_SND_AUTH_MAPS)) != 0) { if (strcasecmp_utf8(state->sasl_username, name) == 0) { found = 1; break; @@ -5920,7 +5937,7 @@ static int rest_update(char **argv) /* rest_class - (re)define a restriction class */ -static void rest_class(char *class) +static void rest_class(const char *pname, char *class) { char *cp = class; char *name; @@ -5929,13 +5946,14 @@ static void rest_class(char *class) if (smtpd_rest_classes == 0) smtpd_rest_classes = htable_create(1); - if ((name = mystrtok(&cp, CHARS_COMMA_SP)) == 0) + if ((name = mystrtok_cw(&cp, CHARS_COMMA_SP, pname)) == 0) msg_panic("rest_class: null class name"); if ((entry = htable_locate(smtpd_rest_classes, name)) != 0) argv_free((ARGV *) entry->value); else entry = htable_enter(smtpd_rest_classes, name, (void *) 0); - entry->value = (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, cp); + entry->value = (void *) smtpd_check_parse(SMTPD_CHECK_PARSE_ALL, + pname, cp); } /* resolve_clnt_init - initialize reply */ @@ -6334,7 +6352,7 @@ int main(int argc, char **argv) } #endif if (strcasecmp(args->argv[0], "restriction_class") == 0) { - rest_class(args->argv[1]); + rest_class("restriction_class", args->argv[1]); resp = 0; break; } diff --git a/postfix/src/tls/tls_certkey.c b/postfix/src/tls/tls_certkey.c index 09a35e017..772f4e7a5 100644 --- a/postfix/src/tls/tls_certkey.c +++ b/postfix/src/tls/tls_certkey.c @@ -79,6 +79,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -460,7 +462,9 @@ static int load_pem_bio(pem_load_state_t *st, int more) static int load_chain_files(SSL_CTX *ctx, const char *chain_files) { pem_load_state_t st; - ARGV *files = argv_split(chain_files, CHARS_COMMA_SP); + + /* XXX Which parameter to blame? */ + ARGV *files = argv_split_cw(chain_files, CHARS_COMMA_SP, "chain_files"); char **filep; int ret = 0; int more; diff --git a/postfix/src/tls/tls_dane.c b/postfix/src/tls/tls_dane.c index a2b9b80d3..d2baf9cc8 100644 --- a/postfix/src/tls/tls_dane.c +++ b/postfix/src/tls/tls_dane.c @@ -187,6 +187,8 @@ /* New York, NY 10011, USA /* /* Viktor Dukhovni +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -418,7 +420,8 @@ static void dane_free(void *dane, void *unused_context) void tls_dane_add_fpt_digests(TLS_DANE *dane, const char *digest, const char *delim, int smtp_mode) { - ARGV *values = argv_split(digest, delim); + /* XXX Which parameter to blame? */ + ARGV *values = argv_split_cw(digest, delim, "fingerprint digests"); ssize_t i; if (smtp_mode) { @@ -850,7 +853,8 @@ void tls_dane_digest_init(SSL_CTX *ctx, const EVP_MD *fpt_alg) maxtype = 2; save = cp = mystrdup(var_tls_dane_digests); - while ((algname = mystrtok(&cp, CHARS_COMMA_SP)) != 0) { + while ((algname = mystrtok_cw(&cp, CHARS_COMMA_SP, + VAR_TLS_DANE_DIGESTS)) != 0) { char *algcode = split_at(algname, '='); int codepoint = -1; diff --git a/postfix/src/tls/tls_dh.c b/postfix/src/tls/tls_dh.c index f47b95461..6d135f6d8 100644 --- a/postfix/src/tls/tls_dh.c +++ b/postfix/src/tls/tls_dh.c @@ -57,6 +57,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -304,11 +306,11 @@ void tls_tmp_dh(SSL_CTX *ctx, int useauto) /* ------------------------------------- Common API */ #define AG_STAT_OK (0) -#define AG_STAT_NO_GROUP (-1) /* no usable group, may retry */ -#define AG_STAT_NO_RETRY (-2) /* other error, don't retry */ +#define AG_STAT_NO_GROUP (-1) /* no usable group, may retry */ +#define AG_STAT_NO_RETRY (-2) /* other error, don't retry */ static int setup_auto_groups(SSL_CTX *ctx, const char *origin, - const char *eecdh, + const char *eecdh, const char *ffdhe) { #ifndef OPENSSL_NO_ECDH @@ -335,12 +337,16 @@ static int setup_auto_groups(SSL_CTX *ctx, const char *origin, } while (0) groups = save = concatenate(eecdh, " ", ffdhe, NULL); - if ((group = mystrtok(&groups, CHARS_COMMA_SP)) == 0) { + /* XXX which parameter to blame? */ + if ((group = mystrtok_cw(&groups, CHARS_COMMA_SP, + "key exchange group")) == 0) { msg_warn("no %s key exchange group - OpenSSL requires at least one", origin); SETUP_AG_RETURN(AG_STAT_NO_GROUP); } - for (; group != 0; group = mystrtok(&groups, CHARS_COMMA_SP)) { + /* XXX which parameter to blame? */ + for (; group != 0; group = mystrtok_cw(&groups, CHARS_COMMA_SP, + "key exchange group")) { int nid = EC_curve_nist2nid(group); if (nid == NID_undef) @@ -405,7 +411,7 @@ void tls_auto_groups(SSL_CTX *ctx, const char *eecdh, const char *ffdhe) * group selection is mere performance tuning and not security critical. * All the groups supported for negotiation should be strong enough. */ - for (origin = "configured"; /* void */ ; /* void */) { + for (origin = "configured"; /* void */ ; /* void */ ) { switch (setup_auto_groups(ctx, origin, eecdh, ffdhe)) { case AG_STAT_OK: return; diff --git a/postfix/src/tls/tls_misc.c b/postfix/src/tls/tls_misc.c index b7000cbab..e9a88c866 100644 --- a/postfix/src/tls/tls_misc.c +++ b/postfix/src/tls/tls_misc.c @@ -235,6 +235,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -611,7 +613,9 @@ int tls_proto_mask_lims(const char *plist, int *floor, int *ceiling) *floor = *ceiling = 0; save = cp = mystrdup(plist); - while ((tok = mystrtok(&cp, CHARS_COMMA_SP ":")) != 0) { + /* XXX Which parameter to blame? */ + while ((tok = mystrtok_cw(&cp, CHARS_COMMA_SP ":", + "protocol exclusions")) != 0) { if (strncmp(tok, ">=", 2) == 0) code = parse_tls_version(tok + 2, floor); else if (strncmp(tok, "<=", 2) == 0) @@ -833,7 +837,9 @@ const char *tls_set_ciphers(TLS_SESS_STATE *TLScontext, const char *grade, #define CIPHER_SEP CHARS_COMMA_SP ":" if (exclusions != 0) { cp = save = mystrdup(exclusions); - while ((tok = mystrtok(&cp, CIPHER_SEP)) != 0) { + /* XXX Which parameter to blame? */ + while ((tok = mystrtok_cw(&cp, CIPHER_SEP, + "cipher exclusions")) != 0) { /* * Can't exclude ciphers that start with modifiers. diff --git a/postfix/src/util/argv.h b/postfix/src/util/argv.h index b0098ce13..157b42b81 100644 --- a/postfix/src/util/argv.h +++ b/postfix/src/util/argv.h @@ -20,7 +20,7 @@ typedef struct ARGV { char **argv; /* string array */ } ARGV; -typedef int (*ARGV_COMPAR_FN)(const void *, const void *); +typedef int (*ARGV_COMPAR_FN) (const void *, const void *); extern ARGV *argv_alloc(ssize_t); extern ARGV *argv_sort(ARGV *); /* backwards compatibility */ @@ -36,13 +36,21 @@ extern void argv_delete(ARGV *, ssize_t, ssize_t); extern ARGV *argv_free(ARGV *); extern ARGV *argv_split(const char *, const char *); +extern ARGV *argv_split_cw(const char *, const char *, const char *); extern ARGV *argv_split_count(const char *, const char *, ssize_t); extern ARGV *argv_split_append(ARGV *, const char *, const char *); +extern ARGV *argv_split_append_cw(ARGV *, const char *, const char *, const char *); + +#define argv_split(cp, sp) argv_split_cw((cp), (sp), (char *) 0) +#define argv_split_append(av, cp, sp) argv_split_append_cw((av), (cp), (sp), (char *) 0) extern ARGV *argv_splitq(const char *, const char *, const char *); +extern ARGV *argv_splitq_cw(const char *, const char *, const char *, const char *); extern ARGV *argv_splitq_count(const char *, const char *, const char *, ssize_t); extern ARGV *argv_splitq_append(ARGV *, const char *, const char *, const char *); +#define argv_splitq(cp, sp, pp) argv_splitq_cw((cp), (sp), (pp), (char *) 0) + extern ARGV *argv_split_at(const char *, int); extern ARGV *argv_split_at_count(const char *, int, ssize_t); extern ARGV *argv_split_at_append(ARGV *, const char *, int); @@ -73,6 +81,8 @@ extern ARGV *argv_split_at_append(ARGV *, const char *, int); /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ #endif diff --git a/postfix/src/util/argv_split.c b/postfix/src/util/argv_split.c index a9f3afbdb..0fd51c9b1 100644 --- a/postfix/src/util/argv_split.c +++ b/postfix/src/util/argv_split.c @@ -10,6 +10,11 @@ /* const char *string; /* const char *delim; /* +/* ARGV *argv_split_cw(string, delim, blame) +/* const char *string; +/* const char *delim; +/* const char *blame; +/* /* ARGV *argv_split_count(string, delim, count) /* const char *string; /* const char *delim; @@ -19,18 +24,37 @@ /* ARGV *argv; /* const char *string; /* const char *delim; +/* +/* ARGV *argv_split_append_cw(argv, string, delim, blame) +/* ARGV *argv; +/* const char *string; +/* const char *delim; +/* const char *blame; /* DESCRIPTION /* argv_split() breaks up \fIstring\fR into tokens according /* to the delimiters specified in \fIdelim\fR. The result is /* a null-terminated string array. /* +/* argv_split_cw() is like argv_split(), but stops splitting +/* input and logs a warning when it encounters text that looks +/* like a trailing comment. The \fBblame\fR argument specifies +/* context that is used in warning messages. Specify a null +/* pointer to disable the trailing comment check. +/* /* argv_split_count() is like argv_split() but stops splitting /* input after at most \fIcount\fR -1 times and leaves the /* remainder, if any, in the last array element. It is an error /* to specify a count < 1. -/* +/* /* argv_split_append() performs the same operation as argv_split(), /* but appends the result to an existing string array. +/* +/* argv_split_append_cw() is like argv_split_append(), but +/* stops splitting input and logs a warning when it encounters +/* text that looks like a trailing comment. The \fBblame\fR +/* argument specifies context that is used in warning messages. +/* Specify a null pointer to disable the trailing comment +/* check. /* SEE ALSO /* mystrtok(), safe string splitter. /* DIAGNOSTICS @@ -44,6 +68,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System libraries. */ @@ -58,16 +84,25 @@ #include "argv.h" #include "msg.h" -/* argv_split - split string into token array */ +/* argv_split - ABI compatibility wrapper */ + +#undef argv_split ARGV *argv_split(const char *string, const char *delim) +{ + return (argv_split_cw(string, delim, (char *) 0)); +} + +/* argv_split_cw - split string into token array and complain about comment */ + +ARGV *argv_split_cw(const char *string, const char *delim, const char *blame) { ARGV *argvp = argv_alloc(1); char *saved_string = mystrdup(string); char *bp = saved_string; char *arg; - while ((arg = mystrtok(&bp, delim)) != 0) + while ((arg = mystrtok_cw(&bp, delim, blame)) != 0) argv_add(argvp, arg, (char *) 0); argv_terminate(argvp); myfree(saved_string); @@ -96,15 +131,25 @@ ARGV *argv_split_count(const char *string, const char *delim, ssize_t count) return (argvp); } -/* argv_split_append - split string into token array, append to array */ +/* argv_split_append - ABI compatibility wrapper */ + +#undef argv_split_append ARGV *argv_split_append(ARGV *argvp, const char *string, const char *delim) +{ + return (argv_split_append_cw(argvp, string, delim, (char *) 0)); +} + +/* argv_split_append_cw - split string into token array, append to array */ + +ARGV *argv_split_append_cw(ARGV *argvp, const char *string, const char *delim, + const char *blame) { char *saved_string = mystrdup(string); char *bp = saved_string; char *arg; - while ((arg = mystrtok(&bp, delim)) != 0) + while ((arg = mystrtok_cw(&bp, delim, blame)) != 0) argv_add(argvp, arg, (char *) 0); argv_terminate(argvp); myfree(saved_string); diff --git a/postfix/src/util/argv_splitq.c b/postfix/src/util/argv_splitq.c index 3900ee117..39b04033a 100644 --- a/postfix/src/util/argv_splitq.c +++ b/postfix/src/util/argv_splitq.c @@ -11,6 +11,12 @@ /* const char *delim; /* const char *parens; /* +/* ARGV *argv_splitq_cw(string, delim, parens, blame) +/* const char *string; +/* const char *delim; +/* const char *parens; +/* const char *blame; +/* /* ARGV *argv_splitq_count(string, delim, parens, count) /* const char *string; /* const char *delim; @@ -28,6 +34,12 @@ /* splitting text between matching parentheses. The result is /* a null-terminated string array. /* +/* argv_splitq_cw() is like argv_splitq() but stops splitting +/* input and logs a warning when it encounters text that looks +/* like a trailing comment. The \fBblame\fR argument specifies +/* context that is used in warning messages. Specify a null +/* pointer to disable the trailing comment check. +/* /* argv_splitq_count() is like argv_splitq() but stops splitting /* input after at most \fIcount\fR -1 times and leaves the /* remainder, if any, in the last array element. It is an error @@ -48,6 +60,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System libraries. */ @@ -62,16 +76,26 @@ #include "argv.h" #include "msg.h" -/* argv_splitq - split string into token array */ +/* argv_splitq - ABI compatibility wrapper */ + +#undef argv_splitq ARGV *argv_splitq(const char *string, const char *delim, const char *parens) +{ + return (argv_splitq_cw(string, delim, parens, (char *) 0)); +} + +/* argv_splitq_cw - split string into token array */ + +ARGV *argv_splitq_cw(const char *string, const char *delim, + const char *parens, const char *blame) { ARGV *argvp = argv_alloc(1); char *saved_string = mystrdup(string); char *bp = saved_string; char *arg; - while ((arg = mystrtokq(&bp, delim, parens)) != 0) + while ((arg = mystrtokq_cw(&bp, delim, parens, blame)) != 0) argv_add(argvp, arg, (char *) 0); argv_terminate(argvp); myfree(saved_string); diff --git a/postfix/src/util/dict_file.c b/postfix/src/util/dict_file.c index c6ea74c9a..054e4b37a 100644 --- a/postfix/src/util/dict_file.c +++ b/postfix/src/util/dict_file.c @@ -70,6 +70,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -114,7 +116,7 @@ VSTRING *dict_file_to_buf(DICT *dict, const char *pathnames) return (retval); \ } while (0); - argv = argv_split(pathnames, CHARS_COMMA_SP); + argv = argv_split_cw(pathnames, CHARS_COMMA_SP, dict->name); if (argv->argc == 0) { vstring_sprintf(dict->file_buf, "empty pathname list: >>%s<<'", pathnames); diff --git a/postfix/src/util/dict_inline.c b/postfix/src/util/dict_inline.c index 72339b2b2..2b5ccf9c2 100644 --- a/postfix/src/util/dict_inline.c +++ b/postfix/src/util/dict_inline.c @@ -31,6 +31,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -112,7 +114,8 @@ DICT *dict_inline_open(const char *name, int open_flags, int dict_flags) */ dict = dict_open3(DICT_TYPE_HT, name, open_flags, dict_flags); dict_type_override(dict, DICT_TYPE_INLINE); - while ((nameval = mystrtokq(&cp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) { + while ((nameval = mystrtokq_cw(&cp, CHARS_COMMA_SP, CHARS_BRACE, + name)) != 0) { if (nameval[0] == CHARS_BRACE[0]) err = free_me = extpar(&nameval, CHARS_BRACE, EXTPAR_FLAG_STRIP); if (err != 0 || (err = split_qnameval(nameval, &vname, &value)) != 0) diff --git a/postfix/src/util/dict_pipe.c b/postfix/src/util/dict_pipe.c index 8ce0faad7..7c4cec666 100644 --- a/postfix/src/util/dict_pipe.c +++ b/postfix/src/util/dict_pipe.c @@ -37,6 +37,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -141,8 +143,8 @@ DICT *dict_pipe_open(const char *name, int open_flags, int dict_flags) */ if ((len = balpar(name, CHARS_BRACE)) == 0 || name[len] != 0 || *(saved_name = mystrndup(name + 1, len - 2)) == 0 - || ((argv = argv_splitq(saved_name, CHARS_COMMA_SP, CHARS_BRACE)), - (argv->argc == 0))) + || ((argv = argv_splitq_cw(saved_name, CHARS_COMMA_SP, CHARS_BRACE, + name)), (argv->argc == 0))) DICT_PIPE_RETURN(dict_surrogate(DICT_TYPE_PIPE, name, open_flags, dict_flags, "bad syntax: \"%s:%s\"; " diff --git a/postfix/src/util/dict_random.c b/postfix/src/util/dict_random.c index 36f79b355..95b724422 100644 --- a/postfix/src/util/dict_random.c +++ b/postfix/src/util/dict_random.c @@ -36,6 +36,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -93,7 +95,7 @@ static char *dict_random_parse_name(DICT *dict, ARGV **argv, VSTRING *b64 = 0; char *err = 0; - while ((arg = mystrtokq(&bp, delim, parens)) != 0) { + while ((arg = mystrtokq_cw(&bp, delim, parens, string)) != 0) { if (dict->flags & DICT_FLAG_SRC_RHS_IS_FILE) { if ((b64 = dict_file_to_b64(dict, arg)) != 0) { argv_add(argvp, vstring_str(b64), (char *) 0); diff --git a/postfix/src/util/dict_stream.c b/postfix/src/util/dict_stream.c index e28ad71fd..a2f09f89f 100644 --- a/postfix/src/util/dict_stream.c +++ b/postfix/src/util/dict_stream.c @@ -51,7 +51,7 @@ /* content as specified above. /* .IP st /* File metadata with the file owner, or fake metadata with the -/* real UID and GID of the dict_stream_open() caller. This is +/* real UID and GID of the dict_stream_open() caller. This is /* used for "taint" tracking (zero=trusted, non-zero=untrusted). /* IP why /* Pointer to pointer to error message storage. dict_stream_open() @@ -66,6 +66,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* @@ -98,7 +100,8 @@ static char *dict_inline_to_multiline(VSTRING *vp, const char *mapname) /* Strip the {} from the map "name". */ err = extpar(&bp, CHARS_BRACE, EXTPAR_FLAG_NONE); /* Extract zero or more rules inside {}. */ - while (err == 0 && (cp = mystrtokq(&bp, CHARS_COMMA_SP, CHARS_BRACE)) != 0) + while (err == 0 + && (cp = mystrtokq_cw(&bp, CHARS_COMMA_SP, CHARS_BRACE, mapname)) != 0) if ((err = extpar(&cp, CHARS_BRACE, EXTPAR_FLAG_STRIP)) == 0) /* Write rule to in-memory file. */ vstring_sprintf_append(vp, "%s\n", cp); diff --git a/postfix/src/util/dict_union.c b/postfix/src/util/dict_union.c index 80df03b61..989950c78 100644 --- a/postfix/src/util/dict_union.c +++ b/postfix/src/util/dict_union.c @@ -41,6 +41,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -154,8 +156,8 @@ DICT *dict_union_open(const char *name, int open_flags, int dict_flags) */ if ((len = balpar(name, CHARS_BRACE)) == 0 || name[len] != 0 || *(saved_name = mystrndup(name + 1, len - 2)) == 0 - || ((argv = argv_splitq(saved_name, CHARS_COMMA_SP, CHARS_BRACE)), - (argv->argc == 0))) + || ((argv = argv_splitq_cw(saved_name, CHARS_COMMA_SP, CHARS_BRACE, + name)), (argv->argc == 0))) DICT_UNION_RETURN(dict_surrogate(DICT_TYPE_UNION, name, open_flags, dict_flags, "bad syntax: \"%s:%s\"; " diff --git a/postfix/src/util/match_list.c b/postfix/src/util/match_list.c index 520485dd0..d8f22f097 100644 --- a/postfix/src/util/match_list.c +++ b/postfix/src/util/match_list.c @@ -84,6 +84,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -145,12 +147,8 @@ static ARGV *match_list_parse(MATCH_LIST *match_list, ARGV *pat_list, * If there is an error, implement graceful degradation by inserting a * pseudo table whose lookups fail with a warning message. */ - while ((start = mystrtokq(&bp, delim, CHARS_BRACE)) != 0) { - if (*start == '#') { - msg_warn("%s: comment at end of line is not supported: %s %s", - match_list->pname, start, bp); - break; - } + while ((start = mystrtokq_cw(&bp, delim, CHARS_BRACE, + match_list->pname)) != 0) { for (match = init_match, item = start; *item == '!'; item++) match = !match; if (*item == 0) diff --git a/postfix/src/util/mystrtok.c b/postfix/src/util/mystrtok.c index 85b15f3b3..a1c743cee 100644 --- a/postfix/src/util/mystrtok.c +++ b/postfix/src/util/mystrtok.c @@ -18,6 +18,22 @@ /* char *mystrtokdq(bufp, delimiters) /* char **bufp; /* const char *delimiters; +/* +/* char *mystrtok_cw(bufp, delimiters, blame) +/* char **bufp; +/* const char *delimiters; +/* const char *blame; +/* +/* char *mystrtokq_cw(bufp, delimiters, parens, blame) +/* char **bufp; +/* const char *delimiters; +/* const char *parens; +/* const char *blame; +/* +/* char *mystrtokdq_cw(bufp, delimiters, blame) +/* char **bufp; +/* const char *delimiters; +/* const char *blame; /* DESCRIPTION /* mystrtok() splits a buffer on the specified \fIdelimiters\fR. /* Tokens are delimited by runs of delimiters, so this routine @@ -38,6 +54,12 @@ /* /* The result value is the next token, or a null pointer when the /* end of the buffer was reached. +/* +/* mystrtok_cw(), mystrtokq_cw(), and mystrtokdq_cw, log a +/* warning and return null when the result would look like +/* comment. The \fBblame\fR argument provides context for +/* warning messages. Specify a null pointer to disable the +/* comment check. /* LICENSE /* .ad /* .fi @@ -52,20 +74,40 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ -#include "sys_defs.h" +#include #include /* Utility library. */ -#include "stringops.h" +#include +#include -/* mystrtok - safe tokenizer */ +/* mystrtok_warn - warn for #comment after other text */ + +static void mystrtok_warn(const char *start, const char *bufp, const char *blame) +{ + msg_warn("%s: #comment after other text is not allowed: %s %s", + blame, start, bufp); +} + +/* mystrtok - ABI compatibility wrapper */ + +#undef mystrtok char *mystrtok(char **src, const char *sep) +{ + return (mystrtok_cw(src, sep, (char *) 0)); +} + +/* mystrtok - safe tokenizer */ + +char *mystrtok_cw(char **src, const char *sep, const char *blame) { char *start = *src; char *end; @@ -86,12 +128,28 @@ char *mystrtok(char **src, const char *sep) if (*end != 0) *end++ = 0; *src = end; - return (start); + + if (blame && *start == '#') { + mystrtok_warn(start, *src, blame); + return (0); + } else { + return (start); + } } -/* mystrtokq - safe tokenizer with quoting support */ +/* mystrtokq - ABI compatibility wrapper */ + +#undef mystrtokq char *mystrtokq(char **src, const char *sep, const char *parens) +{ + return (mystrtokq_cw(src, sep, parens, (char *) 0)); +} + +/* mystrtokq_cw - safe tokenizer with quoting support */ + +char *mystrtokq_cw(char **src, const char *sep, const char *parens, + const char *blame) { char *start = *src; static char *cp; @@ -121,12 +179,30 @@ char *mystrtokq(char **src, const char *sep, const char *parens) } } *src = cp; - return (start); + + /* + * Optional detect a comment. + */ + if (blame && *start == '#') { + mystrtok_warn(start, *src, blame); + return (0); + } else { + return (start); + } } -/* mystrtokdq - safe tokenizer, double quote and backslash support */ +/* mystrtokdq - ABI compatibility wrapper */ + +#undef mystrtokdq char *mystrtokdq(char **src, const char *sep) +{ + return (mystrtokdq_cw(src, sep, (char *) 0)); +} + +/* mystrtokdq_cw - safe tokenizer, double quote and backslash support */ + +char *mystrtokdq_cw(char **src, const char *sep, const char *blame) { char *cp = *src; char *start; @@ -157,7 +233,12 @@ char *mystrtokdq(char **src, const char *sep) } } *src = cp; - return (start); + if (blame && start && *start == '#') { + mystrtok_warn(start, *src, blame); + return (0); + } else { + return (start); + } } #ifdef TEST @@ -195,6 +276,12 @@ static const struct testcase testcases[] = { {"mystrtokdq", " foo\\ bar ", {"foo\\ bar"}}, {"mystrtokdq", " foo \\\" bar", {"foo", "\\\"", "bar"}}, {"mystrtokdq", " foo \" bar baz\" ", {"foo", "\" bar baz\""}}, + {"mystrtok_cw", "#after text"}, + {"mystrtok_cw", "before-text #after text", {"before-text"}}, + {"mystrtokq_cw", "#after text"}, + {"mystrtokq_cw", "{ before text } #after text", "{ before text }"}, + {"mystrtokdq_cw", "#after text"}, + {"mystrtokdq_cw", "\"before text\" #after text", {"\"before text\""}}, }; int main(void) @@ -229,6 +316,12 @@ int main(void) actual = mystrtokq(&cp, CHARS_SPACE, CHARS_BRACE); } else if (strcmp(tp->action, "mystrtokdq") == 0) { actual = mystrtokdq(&cp, CHARS_SPACE); + } else if (strcmp(tp->action, "mystrtok_cw") == 0) { + actual = mystrtok_cw(&cp, CHARS_SPACE, "test"); + } else if (strcmp(tp->action, "mystrtokq_cw") == 0) { + actual = mystrtokq_cw(&cp, CHARS_SPACE, CHARS_BRACE, "test"); + } else if (strcmp(tp->action, "mystrtokdq_cw") == 0) { + actual = mystrtokdq_cw(&cp, CHARS_SPACE, "test"); } else { msg_panic("invalid command: %s", tp->action); } diff --git a/postfix/src/util/mystrtok.ref b/postfix/src/util/mystrtok.ref index 4f920f994..6e0eae801 100644 --- a/postfix/src/util/mystrtok.ref +++ b/postfix/src/util/mystrtok.ref @@ -28,3 +28,21 @@ unknown: RUN test case 13 mystrtokdq > foo \" bar< unknown: PASS test 13 unknown: RUN test case 14 mystrtokdq > foo " bar baz" < unknown: PASS test 14 +unknown: RUN test case 15 mystrtok_cw >#after text< +unknown: warning: test: #comment after other text is not allowed: #after text +unknown: PASS test 15 +unknown: RUN test case 16 mystrtok_cw >before-text #after text< +unknown: warning: test: #comment after other text is not allowed: #after text +unknown: PASS test 16 +unknown: RUN test case 17 mystrtokq_cw >#after text< +unknown: warning: test: #comment after other text is not allowed: #after text +unknown: PASS test 17 +unknown: RUN test case 18 mystrtokq_cw >{ before text } #after text< +unknown: warning: test: #comment after other text is not allowed: #after text +unknown: PASS test 18 +unknown: RUN test case 19 mystrtokdq_cw >#after text< +unknown: warning: test: #comment after other text is not allowed: #after text +unknown: PASS test 19 +unknown: RUN test case 20 mystrtokdq_cw >"before text" #after text< +unknown: warning: test: #comment after other text is not allowed: #after text +unknown: PASS test 20 diff --git a/postfix/src/util/name_mask.c b/postfix/src/util/name_mask.c index 284d4fa9d..90404de98 100644 --- a/postfix/src/util/name_mask.c +++ b/postfix/src/util/name_mask.c @@ -176,6 +176,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -228,7 +230,7 @@ int name_mask_delim_opt(const char *context, const NAME_MASK *table, * Break up the names string, and look up each component in the table. If * the name is found, merge its mask with the result. */ - while ((name = mystrtok(&bp, delim)) != 0) { + while ((name = mystrtok_cw(&bp, delim, context)) != 0) { for (np = table; /* void */ ; np++) { if (np->name == 0) { if ((flags & NAME_MASK_NUMBER) @@ -316,7 +318,7 @@ const char *str_name_mask_opt(VSTRING *buf, const char *context, /* long_name_mask_delim_opt - compute mask corresponding to list of names */ long long_name_mask_delim_opt(const char *context, - const LONG_NAME_MASK * table, + const LONG_NAME_MASK *table, const char *names, const char *delim, int flags) { @@ -342,7 +344,7 @@ long long_name_mask_delim_opt(const char *context, * Break up the names string, and look up each component in the table. If * the name is found, merge its mask with the result. */ - while ((name = mystrtok(&bp, delim)) != 0) { + while ((name = mystrtok_cw(&bp, delim, context)) != 0) { for (np = table; /* void */ ; np++) { if (np->name == 0) { if ((flags & NAME_MASK_NUMBER) @@ -378,7 +380,7 @@ long long_name_mask_delim_opt(const char *context, /* str_long_name_mask_opt - mask to string */ const char *str_long_name_mask_opt(VSTRING *buf, const char *context, - const LONG_NAME_MASK * table, + const LONG_NAME_MASK *table, long mask, int flags) { const char *myname = "name_mask"; diff --git a/postfix/src/util/spawn_command.c b/postfix/src/util/spawn_command.c index 739e0125b..8a396a593 100644 --- a/postfix/src/util/spawn_command.c +++ b/postfix/src/util/spawn_command.c @@ -73,6 +73,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -276,7 +278,8 @@ WAIT_STATUS_T spawn_command(int key,...) execvp(args.argv[0], args.argv); msg_fatal("%s: execvp %s: %m", myname, args.argv[0]); } else if (args.shell && *args.shell) { - argv = argv_split(args.shell, CHARS_SPACE); + /* XXX Which parameter to blame? */ + argv = argv_split_cw(args.shell, CHARS_SPACE, "command_shell"); argv_add(argv, args.command, (char *) 0); argv_terminate(argv); execvp(argv->argv[0], argv->argv); diff --git a/postfix/src/util/stringops.h b/postfix/src/util/stringops.h index 8ac177b92..cd9b5753b 100644 --- a/postfix/src/util/stringops.h +++ b/postfix/src/util/stringops.h @@ -31,8 +31,15 @@ extern char *concatenate(const char *,...); extern char *mystrtok(char **, const char *); extern char *mystrtokq(char **, const char *, const char *); extern char *mystrtokdq(char **, const char *); +extern char *mystrtok_cw(char **, const char *, const char *); +extern char *mystrtokq_cw(char **, const char *, const char *, const char *); +extern char *mystrtokdq_cw(char **, const char *, const char *); extern char *translit(char *, const char *, const char *); +#define mystrtok(cp, sp) mystrtok_cw((cp), (sp), (char *) 0) +#define mystrtokq(cp, sp, pp) mystrtokq_cw((cp), (sp), (pp), (char *) 0) +#define mystrtokdq(cp, sp) mystrtokdq_cw((cp), (sp), (char *) 0) + #define printable(string, replacement) \ printable_except((string), (replacement), (char *) 0) @@ -102,6 +109,8 @@ extern int strncasecmp_utf8x(int, const char *, const char *, ssize_t); /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ #endif diff --git a/postfix/src/util/vstream_popen.c b/postfix/src/util/vstream_popen.c index d00d49e66..9e246ae5d 100644 --- a/postfix/src/util/vstream_popen.c +++ b/postfix/src/util/vstream_popen.c @@ -82,6 +82,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -255,7 +257,8 @@ VSTREAM *vstream_popen(int flags,...) execvp(args.argv[0], args.argv); msg_fatal("%s: execvp %s: %m", myname, args.argv[0]); } else if (args.shell && *args.shell) { - argv = argv_split(args.shell, CHARS_SPACE); + /* XXX Which parameter to blame? */ + argv = argv_split_cw(args.shell, CHARS_SPACE, "command_shell"); argv_add(argv, args.command, (char *) 0); argv_terminate(argv); execvp(argv->argv[0], argv->argv);