Re: Null pointer dereference

Bernhard Voelker <[email protected]>
Newsgroups gmane.comp.gnu.findutils.patches,gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
On 2/9/24 19:13, John Seth Thielemann wrote:
 > Building with a gcc nolibc / musl / linux setup found a null pointer dereference in the pred_and handling.
 >
 > Take care,
 > J. Seth Thielemann

Thanks for the patch, but ...

 > diff -Naur /musl/opt/findutils-4.9.0/build/findutils-4.9.0.pristine/find/pred.c /musl/opt/findutils-4.9.0/build>
/findutils-4.9.0/find/pred.c
 > --- /musl/opt/findutils-4.9.0/build/findutils-4.9.0.pristine/find/pred.c	2022-01-02 23:34:22.000000000 +0000
 > +++ /musl/opt/findutils-4.9.0/build/findutils-4.9.0/find/pred.c	2024-02-09 01:32:12.395992857 +0000
 > @@ -150,7 +150,14 @@
 >  bool
 >  pred_and (const char *pathname, struct stat *stat_buf, struct predicate *pred_ptr)
 >  {
 > -  if (pred_ptr->pred_left == NULL
 > +	if (pred_ptr->pred_left == NULL) {
 > +		if (pred_ptr->pred_right)
 > +			return apply_predicate(pathname, stat_buf, pred_ptr->pred_right);
 > +		else
 > +			return false;
 > +	}
 > +
 > +  if (pred_ptr->pred_left->pred_func
 >        || apply_predicate (pathname, stat_buf, pred_ptr->pred_left))
 >      {
 >        return apply_predicate (pathname, stat_buf, pred_ptr->pred_right);

... this breaks most of the tests.

Have a nice day,
Berny
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.