diff options
| author | Kristof Provost <kp@FreeBSD.org> | 2026-07-13 13:14:10 +0000 |
|---|---|---|
| committer | Kristof Provost <kp@FreeBSD.org> | 2026-07-15 11:44:59 +0000 |
| commit | ddbf89234312791e65991efff39a18a9e8e4d077 (patch) | |
| tree | 28974184de320b222e1a7430481dfce8befc0053 | |
| parent | b3b4763bc1ed328013498a958f0af53ceca2d495 (diff) | |
pfctl: fix CREATE_TABLE error handling
pfr_add_table() does not set errno, it returns an error (now).
Read the error code from the return value so we display the correct
error message to the user.
Sponsored by: Rubicon Communications, LLC ("Netgate")
| -rw-r--r-- | sbin/pfctl/pfctl_table.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c index aae347712547..aec02c493f1b 100644 --- a/sbin/pfctl/pfctl_table.c +++ b/sbin/pfctl/pfctl_table.c @@ -85,14 +85,15 @@ static const char *istats_text[2][2][2] = { } while (0) #define CREATE_TABLE do { \ + int _ret; \ warn_duplicate_tables(table.pfrt_name, \ table.pfrt_anchor); \ table.pfrt_flags |= PFR_TFLAG_PERSIST; \ if ((!(opts & PF_OPT_NOACTION) || \ (opts & PF_OPT_DUMMYACTION)) && \ - (pfr_add_table(&table, &nadd, flags)) && \ - (errno != EPERM)) { \ - warnx("%s", pf_strerror(errno)); \ + (_ret = pfr_add_table(&table, &nadd, flags)) && \ + (_ret != EPERM)) { \ + warnx("%s", pf_strerror(_ret)); \ goto _error; \ } \ if (nadd) { \ |
