| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# This tests for the bug corrected in commit 5afa5a164ff1c066af1ec56d875b91562882bd50. |
| 4 |
# Sets were added to the table before checking for errors, and not removed from |
| 5 |
# the table on error, leading to an uninitialized set in the table, causing a |
| 6 |
# segfault for rules that tried to use it. |
| 7 |
# In this case, nft should error out because the set doesn't exist instead of |
| 8 |
# segfaulting |
| 9 |
|
| 10 |
RULESET=" |
| 11 |
add table t |
| 12 |
add chain t c |
| 13 |
add set t s {type ipv4_addr\;} |
| 14 |
add rule t c ip saddr @s |
| 15 |
" |
| 16 |
|
| 17 |
$NFT -f - <<< "$RULESET" |
| 18 |
ret=$? |
| 19 |
|
| 20 |
trap - EXIT |
| 21 |
if [[ $ret -eq 1 ]]; then |
| 22 |
exit 0 |
| 23 |
else |
| 24 |
exit 1 |
| 25 |
fi |