summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorBernhard Voelker <mail@bernhard-voelker.de>2021-08-07 02:18:05 +0200
committerBernhard Voelker <mail@bernhard-voelker.de>2021-08-18 08:36:37 +0200
commita5659a42fa2db0263ca45b1f1806f32c04505dc8 (patch)
tree19c5c16e84508b99ff69d407074a64bc2bc97b62 /build-aux
parent70aede7af92b11ba0fb99ce83abe66b45cc8cc13 (diff)
downloadfindutils-a5659a42fa2db0263ca45b1f1806f32c04505dc8.tar.gz
tree.c: avoid segfault with closing parenthesis ')' after -files0-from
Prompted by the following warning of GCC-11.1.1: tree.c: In function 'get_expr': tree.c:140:31: warning: dereference of NULL 'prev_pred' [CWE-476] \ [-Wanalyzer-null-dereference] 140 | if ((UNI_OP == prev_pred->p_type | ~~~~~~~~~^~~~~~~~ Former versions of find are not vulnerable to this, because a closing parenthesis ')' without anything before was treated as a pathname rather than an option. But this is possible now with the recent introduction of the -files0-from option (see commit 11576f4e6a) - yet still an invalid invocation. Reproducer for a crash: $ find -files0-from FILE ')' -print Segmentation fault (core dumped) In the similar case when the user didn't specify any action, and find(1) adds the default action via '( user-expr ) -print', the error diagnostic was very confusing, too: $ find -files0-from FILE ')' find: invalid expression; empty parentheses are not allowed. * find/tree.c (get_expr): Handle the cases when there's no predicate before CLOSE_PAREN, and output a useful error diagnostic. * tests/find/files0-from.sh: Add a test case for it.
Diffstat (limited to 'build-aux')
0 files changed, 0 insertions, 0 deletions