From a4a6fa15dcf9d104762fd59a4a56ba9f6446fb86 Mon Sep 17 00:00:00 2001 From: Wietse Venema Date: Sun, 9 Apr 2023 00:00:00 -0500 Subject: [PATCH] postfix-3.8-20230409 --- postfix/HISTORY | 22 ++++--- postfix/WISHLIST | 3 + postfix/proto/stop.double-history | 1 + postfix/proto/stop.spell-history | 3 + postfix/src/dns/dns_rr.c | 4 +- postfix/src/global/mail_version.h | 2 +- postfix/src/postconf/Makefile.in | 12 +++- postfix/src/postconf/postconf.h | 4 ++ postfix/src/postconf/postconf_dbms.c | 15 +++-- postfix/src/postconf/postconf_edit.c | 12 ++-- postfix/src/postconf/postconf_main.c | 7 ++- postfix/src/postconf/postconf_master.c | 7 ++- postfix/src/postconf/postconf_misc.c | 48 +++++++++++++++ postfix/src/postconf/test58.ref | 4 +- postfix/src/postconf/test71.ref | 8 +-- postfix/src/postlogd/Makefile.in | 3 +- postfix/src/util/Makefile.in | 12 +++- postfix/src/util/inet_prefix_top.c | 81 ++++++++++++++++++++++++++ 18 files changed, 205 insertions(+), 43 deletions(-) diff --git a/postfix/HISTORY b/postfix/HISTORY index 81d5e00d0..5fa9b3b9f 100644 --- a/postfix/HISTORY +++ b/postfix/HISTORY @@ -27025,14 +27025,22 @@ Apologies for any names omitted. double-free() attempt. Reported by Florian Piekert. File: dns/dns_rr.c. - Usability: Postfix does not support #comments after other - text, but people add them anyway, with unexpected results. - The postconf command now warns for trailing comments in - main.cf files. Similar warnings are planned for database - client configuration files. Files: util/mystrtok.c, + Usability: The postconf command now warns for trailing + comments in Postfix parameter values. Also refactored comment + warnings in match lists. Files: util/mystrtok.c, util/mystrtok.ref, util/match_list.c, global/namadr_list.ref, postconf/postconf_dbms.c, postconf/test71.ref. - TODO: #comment after text in DB client configuration files. + Cleanup: some postconf warnings did not include the full + main.cf or master.cf pathname, complicating the analysis + of multi-instance configurations. Also refactored ad-hoc + code that computed full main.cf or master.cf pathnames. + Files: postconf/postconf.h, postconf/postconf_dbms.c, + postconf/postconf_edit.c, postconf/postconf_main.c, + postconf/postconf_master.c, postconf/postconf_misc.c. + + Cleanup: eliminated unused libdns dependencies. Files: + postlogd/Makefile.in. - TOIDO: test for dns_rr_copy() + dns_rr_free(). + Cleanup: added inet_prefix_top() tests. File: + util/inet_prefix_top.c. diff --git a/postfix/WISHLIST b/postfix/WISHLIST index a83418605..bc52ebc01 100644 --- a/postfix/WISHLIST +++ b/postfix/WISHLIST @@ -21,6 +21,9 @@ Wish list: Multi-recipient support in sender/recipient_bcc_maps and always_bcc. + Test for dns_rr_copy() + dns_rr_free(). + + mail_conf_xxx supprt for non-negative numbers (i.e. numbers with a lower bound of zero). diff --git a/postfix/proto/stop.double-history b/postfix/proto/stop.double-history index 9f05f29e3..c1026c8a0 100644 --- a/postfix/proto/stop.double-history +++ b/postfix/proto/stop.double-history @@ -39,3 +39,4 @@ proto proto SASL_README html proto SQLITE_README html util inet_prefix_top hc smtpd smtpd c smtpd smtpd_peer c File smtp smtp h manpage File postscreen postscreen c + Files postconf postconf h postconf postconf_dbms c diff --git a/postfix/proto/stop.spell-history b/postfix/proto/stop.spell-history index 669c2e3f9..096da091a 100644 --- a/postfix/proto/stop.spell-history +++ b/postfix/proto/stop.spell-history @@ -53,3 +53,6 @@ Aleksandr Stankevic Gallagher Valgrind +Florian +Piekert +refactored diff --git a/postfix/src/dns/dns_rr.c b/postfix/src/dns/dns_rr.c index b84349267..3fde10e58 100644 --- a/postfix/src/dns/dns_rr.c +++ b/postfix/src/dns/dns_rr.c @@ -209,11 +209,11 @@ DNS_RR *dns_rr_copy(DNS_RR *src) * Note: struct copy, because dns_rr_create() would not copy all fields. */ dst = (DNS_RR *) mymalloc(sizeof(*dst)); - memcpy((void *) dst, (void *) src, sizeof(*dst)); + *dst = *src; dst->qname = mystrdup(src->qname); dst->rname = mystrdup(src->rname); if (dst->data) - dst->data = mymemdup(dst->data, dst->data_len); + dst->data = mymemdup(src->data, src->data_len); dst->next = 0; return (dst); } diff --git a/postfix/src/global/mail_version.h b/postfix/src/global/mail_version.h index dbcfba979..9dcb7bd06 100644 --- a/postfix/src/global/mail_version.h +++ b/postfix/src/global/mail_version.h @@ -20,7 +20,7 @@ * Patches change both the patchlevel and the release date. Snapshots have no * patchlevel; they change the release date only. */ -#define MAIL_RELEASE_DATE "20230406" +#define MAIL_RELEASE_DATE "20230409" #define MAIL_VERSION_NUMBER "3.8" #ifdef SNAPSHOT diff --git a/postfix/src/postconf/Makefile.in b/postfix/src/postconf/Makefile.in index 26e747c7b..f0cc4002a 100644 --- a/postfix/src/postconf/Makefile.in +++ b/postfix/src/postconf/Makefile.in @@ -970,13 +970,19 @@ test71: $(PROG) test71.ref rm -f main.cf master.cf touch main.cf master.cf echo "smtpd_client_restrictions = inline:{" >>main.cf - echo " { aaa0 = #aaa1 } #aaa2" >>main.cf + echo " {" >>main.cf + echo " aaa0 = #aaa1" >>main.cf + echo " } #aaa2" >>main.cf echo " }" >>main.cf echo "smtpd_helo_restrictions = pcre:{" >>main.cf - echo " { /bbb0 #bbb1/ } #bbb2" >>main.cf + echo " {" >>main.cf + echo " /bbb0 #bbb1/" >>main.cf + echo " } #bbb2" >>main.cf echo " }" >>main.cf echo "smtpd_sender_restrictions = regexp:{" >>main.cf - echo " { /ccc0 #ccc1/ } #ccc2" >>main.cf + echo " {" >>main.cf + echo " /ccc0 #ccc1/" >>main.cf + echo " } #ccc2" >>main.cf echo " }" >>main.cf touch -t 197101010000 main.cf $(HTABLE_FIX) $(SHLIB_ENV) $(VALGRIND) ./$(PROG) -nc . >test71.tmp 2>&1 diff --git a/postfix/src/postconf/postconf.h b/postfix/src/postconf/postconf.h index 7b23380a5..d11d66fd3 100644 --- a/postfix/src/postconf/postconf.h +++ b/postfix/src/postconf/postconf.h @@ -171,6 +171,8 @@ extern int pcf_cmd_mode; * postconf_misc.c. */ extern void pcf_set_config_dir(void); +extern const char *pcf_get_main_path(void); +extern const char *pcf_get_master_path(void); /* * postconf_main.c @@ -324,4 +326,6 @@ extern void pcf_show_tls(const char *); /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ diff --git a/postfix/src/postconf/postconf_dbms.c b/postfix/src/postconf/postconf_dbms.c index 622e7a01d..b2777cb2e 100644 --- a/postfix/src/postconf/postconf_dbms.c +++ b/postfix/src/postconf/postconf_dbms.c @@ -248,15 +248,15 @@ static void pcf_register_dbms_helper(char *str_value, * database or some other text. */ while ((db_type = mystrtokq_cw(&str_value, CHARS_COMMA_SP, CHARS_BRACE, - local_scope ? MASTER_CONF_FILE : MAIN_CONF_FILE)) != 0) { + local_scope ? pcf_get_master_path() : pcf_get_main_path())) != 0) { if (*db_type == CHARS_BRACE[0]) { if ((err = extpar(&db_type, CHARS_BRACE, EXTPAR_FLAG_NONE)) != 0) { /* XXX Encapsulate this in pcf_warn() function. */ if (local_scope) - msg_warn("%s:%s: %s", - MASTER_CONF_FILE, local_scope->name_space, err); + msg_warn("%s:%s: %s", pcf_get_master_path(), + local_scope->name_space, err); else - msg_warn("%s: %s", MAIN_CONF_FILE, err); + msg_warn("%s: %s", pcf_get_main_path(), err); myfree(err); } if (recurse) @@ -310,11 +310,10 @@ static void pcf_register_dbms_helper(char *str_value, if ((err = extpar(&prefix, CHARS_BRACE, EXTPAR_FLAG_NONE)) != 0) { /* XXX Encapsulate this in pcf_warn() function. */ if (local_scope) - msg_warn("%s:%s: %s", - MASTER_CONF_FILE, local_scope->name_space, - err); + msg_warn("%s:%s: %s", pcf_get_master_path(), + local_scope->name_space, err); else - msg_warn("%s: %s", MAIN_CONF_FILE, err); + msg_warn("%s: %s", pcf_get_main_path(), err); myfree(err); } for (dp = pcf_dbms_info; dp->db_type != 0; dp++) { diff --git a/postfix/src/postconf/postconf_edit.c b/postfix/src/postconf/postconf_edit.c index c60cb06f5..fc097d041 100644 --- a/postfix/src/postconf/postconf_edit.c +++ b/postfix/src/postconf/postconf_edit.c @@ -61,6 +61,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -147,7 +149,7 @@ static void pcf_gobble_cf_line(VSTRING *full_entry_buf, VSTRING *line_buf, void pcf_edit_main(int mode, int argc, char **argv) { - char *path; + const char *path; EDIT_FILE *ep; VSTREAM *src; VSTREAM *dst; @@ -203,7 +205,7 @@ void pcf_edit_main(int mode, int argc, char **argv) * don't leave behind thrash with random names. */ pcf_set_config_dir(); - path = concatenate(var_config_dir, "/", MAIN_CONF_FILE, (char *) 0); + path = pcf_get_main_path(); if ((ep = edit_file_open(path, O_CREAT | O_WRONLY, 0644)) == 0) msg_fatal("open %s%s: %m", path, EDIT_FILE_SUFFIX); dst = ep->tmp_fp; @@ -272,7 +274,6 @@ void pcf_edit_main(int mode, int argc, char **argv) /* * Cleanup. */ - myfree(path); vstring_free(buf); vstring_free(key); htable_free(table, myfree); @@ -296,7 +297,7 @@ typedef struct { void pcf_edit_master(int mode, int argc, char **argv) { const char *myname = "pcf_edit_master"; - char *path; + const char *path; EDIT_FILE *ep; VSTREAM *src; VSTREAM *dst; @@ -401,7 +402,7 @@ void pcf_edit_master(int mode, int argc, char **argv) * don't leave behind thrash with random names. */ pcf_set_config_dir(); - path = concatenate(var_config_dir, "/", MASTER_CONF_FILE, (char *) 0); + path = pcf_get_master_path(); if ((ep = edit_file_open(path, O_CREAT | O_WRONLY, 0644)) == 0) msg_fatal("open %s%s: %m", path, EDIT_FILE_SUFFIX); dst = ep->tmp_fp; @@ -566,7 +567,6 @@ void pcf_edit_master(int mode, int argc, char **argv) /* * Cleanup. */ - myfree(path); vstring_free(line_buf); vstring_free(parse_buf); vstring_free(full_entry_buf); diff --git a/postfix/src/postconf/postconf_main.c b/postfix/src/postconf/postconf_main.c index 8e6e226f3..f19ba7ffb 100644 --- a/postfix/src/postconf/postconf_main.c +++ b/postfix/src/postconf/postconf_main.c @@ -68,6 +68,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -104,17 +106,16 @@ void pcf_read_parameters(void) { - char *path; + const char *path; /* * A direct rip-off of mail_conf_read(). XXX Avoid code duplication by * better code decomposition. */ pcf_set_config_dir(); - path = concatenate(var_config_dir, "/", MAIN_CONF_FILE, (char *) 0); + path = pcf_get_main_path(); if (dict_load_file_xt(CONFIG_DICT, path) == 0) msg_fatal("open %s: %m", path); - myfree(path); } /* pcf_set_parameters - add or override name=value pairs */ diff --git a/postfix/src/postconf/postconf_master.c b/postfix/src/postconf/postconf_master.c index 687e03fdf..af58c1efa 100644 --- a/postfix/src/postconf/postconf_master.c +++ b/postfix/src/postconf/postconf_master.c @@ -137,6 +137,8 @@ /* Google, Inc. /* 111 8th Avenue /* New York, NY 10011, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -411,7 +413,7 @@ const char *pcf_parse_master_entry(PCF_MASTER_ENT *masterp, const char *buf) void pcf_read_master(int fail_on_open_error) { const char *myname = "pcf_read_master"; - char *path; + const char *path; VSTRING *buf; VSTREAM *fp; const char *err; @@ -430,7 +432,7 @@ void pcf_read_master(int fail_on_open_error) */ if (var_config_dir == 0) pcf_set_config_dir(); - path = concatenate(var_config_dir, "/", MASTER_CONF_FILE, (char *) 0); + path = pcf_get_master_path(); /* * Initialize the in-memory master table. @@ -463,7 +465,6 @@ void pcf_read_master(int fail_on_open_error) * Null-terminate the master table and clean up. */ pcf_master_table[entry_count].argv = 0; - myfree(path); } /* pcf_print_master_entry - print one master line */ diff --git a/postfix/src/postconf/postconf_misc.c b/postfix/src/postconf/postconf_misc.c index 0107651fb..d8a5008a3 100644 --- a/postfix/src/postconf/postconf_misc.c +++ b/postfix/src/postconf/postconf_misc.c @@ -7,11 +7,20 @@ /* #include /* /* void pcf_set_config_dir() +/* +/* const char *pcf_get_main_path() +/* +/* const char *pcf_get_master_path() /* DESCRIPTION /* pcf_set_config_dir() forcibly overrides the var_config_dir /* parameter setting with the value from the environment or /* with the default pathname, and updates the mail parameter /* dictionary. +/* +/* pcf_get_main_path() and pcf_get_master_path() return a +/* pointer to a cached main.cf or master.cf full pathname, +/* based on the current var_config_dir setting. The functions +/* call pcf_set_config_dir() when no full pathname is cached. /* DIAGNOSTICS /* Problems are reported to the standard error stream. /* LICENSE @@ -23,6 +32,8 @@ /* IBM T.J. Watson Research /* P.O. Box 704 /* Yorktown Heights, NY 10598, USA +/* +/* Wietse Venema /*--*/ /* System library. */ @@ -33,6 +44,7 @@ #include #include +#include /* Global library. */ @@ -43,6 +55,12 @@ #include + /* + * Pathname cache, based on current var_config_dir. + */ +static char *pcf_main_path = 0; +static char *pcf_master_path = 0; + /* pcf_set_config_dir - forcibly override var_config_dir */ void pcf_set_config_dir(void) @@ -57,4 +75,34 @@ void pcf_set_config_dir(void) } else { var_config_dir = mystrdup(DEF_CONFIG_DIR); } + + /* + * Populate the full pathname cache. + */ + if (pcf_main_path) + myfree(pcf_main_path); + pcf_main_path = + concatenate(var_config_dir, "/", MAIN_CONF_FILE, (char *) 0); + if (pcf_master_path) + myfree(pcf_master_path); + pcf_master_path = + concatenate(var_config_dir, "/", MASTER_CONF_FILE, (char *) 0); +} + +/* pcf_get_main_path - generate and return full main.cf pathname */ + +const char *pcf_get_main_path(void) +{ + if (pcf_main_path == 0) + pcf_set_config_dir(); + return (pcf_main_path); +} + +/* pcf_get_master_path - generate and return full master.cf pathname */ + +const char *pcf_get_master_path(void) +{ + if (pcf_master_path == 0) + pcf_set_config_dir(); + return (pcf_master_path); } diff --git a/postfix/src/postconf/test58.ref b/postfix/src/postconf/test58.ref index ac24a4d31..7877dbec1 100644 --- a/postfix/src/postconf/test58.ref +++ b/postfix/src/postconf/test58.ref @@ -1,5 +1,5 @@ -./postconf: warning: main.cf: syntax error after '}' in "{ldap:xxx, memcache:yy}x" -./postconf: warning: main.cf: missing '}' in "{xx" +./postconf: warning: ./main.cf: syntax error after '}' in "{ldap:xxx, memcache:yy}x" +./postconf: warning: ./main.cf: missing '}' in "{xx" config_directory = . mydestination = foo bar pipemap:{ldap:xxx, memcache:yy}x randmap:{xx xxx_domain = foo diff --git a/postfix/src/postconf/test71.ref b/postfix/src/postconf/test71.ref index 1c4be0cae..3236bdc97 100644 --- a/postfix/src/postconf/test71.ref +++ b/postfix/src/postconf/test71.ref @@ -1,7 +1,7 @@ -./postconf: warning: main.cf: #comment after other text is not allowed: #aaa1 ... -./postconf: warning: main.cf: #comment after other text is not allowed: #aaa2 ... -./postconf: warning: main.cf: #comment after other text is not allowed: #ccc2 ... -./postconf: warning: main.cf: #comment after other text is not allowed: #bbb2 ... +./postconf: warning: ./main.cf: #comment after other text is not allowed: #aaa1 ... +./postconf: warning: ./main.cf: #comment after other text is not allowed: #aaa2 ... +./postconf: warning: ./main.cf: #comment after other text is not allowed: #ccc2 ... +./postconf: warning: ./main.cf: #comment after other text is not allowed: #bbb2 ... config_directory = . smtpd_client_restrictions = inline:{ { aaa0 = #aaa1 } #aaa2 } smtpd_helo_restrictions = pcre:{ { /bbb0 #bbb1/ } #bbb2 } diff --git a/postfix/src/postlogd/Makefile.in b/postfix/src/postlogd/Makefile.in index 21fad76dd..d3d8e938b 100644 --- a/postfix/src/postlogd/Makefile.in +++ b/postfix/src/postlogd/Makefile.in @@ -8,8 +8,7 @@ CFLAGS = $(DEBUG) $(OPT) $(DEFS) TESTPROG= PROG = postlogd INC_DIR = ../../include -LIBS = ../../lib/lib$(LIB_PREFIX)dns$(LIB_SUFFIX) \ - ../../lib/lib$(LIB_PREFIX)master$(LIB_SUFFIX) \ +LIBS = ../../lib/lib$(LIB_PREFIX)master$(LIB_SUFFIX) \ ../../lib/lib$(LIB_PREFIX)global$(LIB_SUFFIX) \ ../../lib/lib$(LIB_PREFIX)util$(LIB_SUFFIX) diff --git a/postfix/src/util/Makefile.in b/postfix/src/util/Makefile.in index a3700f568..f69dec58e 100644 --- a/postfix/src/util/Makefile.in +++ b/postfix/src/util/Makefile.in @@ -145,7 +145,7 @@ TESTPROG= dict_open dup2_pass_on_exec events exec_command fifo_open \ vstream timecmp dict_cache midna_domain casefold strcasecmp_utf8 \ vbuf_print split_qnameval vstream msg_logger byte_mask \ known_tcp_ports dict_stream find_inet binhash hash_fnv argv \ - clean_env + clean_env inet_prefix_top PLUGIN_MAP_SO = $(LIB_PREFIX)pcre$(LIB_SUFFIX) $(LIB_PREFIX)lmdb$(LIB_SUFFIX) \ $(LIB_PREFIX)cdb$(LIB_SUFFIX) $(LIB_PREFIX)sdbm$(LIB_SUFFIX) HTABLE_FIX = NORANDOMIZE=1 @@ -604,6 +604,11 @@ argv: $(LIB) $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) mv junk $@.o +inet_prefix_top: $(LIB) + mv $@.o junk + $(CC) $(CFLAGS) -DTEST -o $@ $@.c $(LIB) $(SYSLIBS) + mv junk $@.o + tests: all valid_hostname_test mac_expand_test dict_test unescape_test \ hex_quote_test ctable_test inet_addr_list_test base64_code_test \ attr_scan64_test attr_scan0_test host_port_test dict_tests \ @@ -613,7 +618,7 @@ tests: all valid_hostname_test mac_expand_test dict_test unescape_test \ strcasecmp_utf8_test vbuf_print_test miss_endif_cidr_test \ miss_endif_regexp_test split_qnameval_test vstring_test \ vstream_test byte_mask_tests mystrtok_test known_tcp_ports_test \ - binhash_test argv_test + binhash_test argv_test inet_prefix_top_test dict_tests: all dict_test \ dict_pcre_tests dict_cidr_test dict_thash_test dict_static_test \ @@ -1075,6 +1080,9 @@ find_inet_test: find_inet find_inet.ref argv_test: argv $(SHLIB_ENV) ${VALGRIND} ./argv +inet_prefix_top_test: inet_prefix_top + $(SHLIB_ENV) ${VALGRIND} ./inet_prefix_top + depend: $(MAKES) (sed '1,/^# do not edit/!d' Makefile.in; \ set -e; for i in [a-z][a-z0-9]*.c; do \ diff --git a/postfix/src/util/inet_prefix_top.c b/postfix/src/util/inet_prefix_top.c index 56da5ddac..017209688 100644 --- a/postfix/src/util/inet_prefix_top.c +++ b/postfix/src/util/inet_prefix_top.c @@ -100,3 +100,84 @@ char *inet_prefix_top(int af, const void *src, int prefix_len) vstring_sprintf_append(buf, "/%d", prefix_len); return (vstring_export(buf)); } + +#ifdef TEST + +#include +#include + + /* + * TODO: add test cases for fatal and panic errors, intercept msg_fatal() + * and msg_panic(), and verify the expected error messages. + */ +typedef struct TEST_CASE { + int in_af; + const char *in_address; + int in_prefix_len; + const char *exp_prefix; +} TEST_CASE; + +static TEST_CASE test_cases[] = { + AF_INET, "255.255.255.255", 32, "255.255.255.255", + AF_INET, "255.255.255.255", 28, "255.255.255.240/28", + AF_INET, "255.255.255.255", 4, "240.0.0.0/4", + AF_INET, "255.255.255.255", 0, "0.0.0.0/0", + AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 128, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", + AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 124, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:fff0/124", + AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 4, "f000::/4", + AF_INET6, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", 0, "::/0", +}; + +#define TEST_CASE_COUNT (sizeof(test_cases) / sizeof(test_cases[0])) + +int main(int argc, char **argv) +{ + TEST_CASE *tp; + union { + struct in_addr in_addr; + struct in6_addr in6_addr; + } u; + char *act_prefix; + int pass = 0; + int fail = 0; + + msg_vstream_init(argv[0], VSTREAM_ERR); + + for (tp = test_cases; tp < test_cases + TEST_CASE_COUNT; tp++) { + msg_info("RUN %s/%d -> %s", tp->in_address, tp->in_prefix_len, + tp->exp_prefix); + switch (inet_pton(tp->in_af, tp->in_address, &u)) { + case -1: + msg_warn("inet_pton(af = %d, src = \"%s\", &u) failed: %m", + tp->in_af, tp->in_address); + fail += 1; + msg_info("FAIL %s/%d -> %s", tp->in_address, tp->in_prefix_len, + tp->exp_prefix); + break; + default: + msg_warn("inet_pton(af = %d, src = \"%s\", &u) failed", + tp->in_af, tp->in_address); + fail += 1; + msg_info("FAIL %s/%d -> %s", tp->in_address, tp->in_prefix_len, + tp->exp_prefix); + break; + case 1: + act_prefix = inet_prefix_top(tp->in_af, &u, tp->in_prefix_len); + if (strcmp(act_prefix, tp->exp_prefix) != 0) { + msg_warn("got \"%s\", want \"%s\"", act_prefix, tp->exp_prefix); + fail += 1; + msg_info("FAIL %s/%d -> %s", tp->in_address, tp->in_prefix_len, + tp->exp_prefix); + } else { + pass += 1; + msg_info("PASS %s/%d -> %s", tp->in_address, tp->in_prefix_len, + tp->exp_prefix); + } + break; + } + } + msg_info("PASS=%d FAIL=%d", pass, fail); + return (fail > 0); +} + +#endif /* TEST */ -- 2.47.3