]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r286344: find: Fix segfault with very long path in -exec/-ok ... {} \;.
authorjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 28 Aug 2015 20:53:08 +0000 (20:53 +0000)
committerjilles <jilles@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 28 Aug 2015 20:53:08 +0000 (20:53 +0000)
commit51519739177437ed2b2337fab59bc5721c3f22a0
tree95afb4bdf6c2df78b6446422273e67f919cac46e
parentc882c4888a64643b2b9dc9d656fdda27236f1d9f
MFC r286344: find: Fix segfault with very long path in -exec/-ok ... {} \;.

If the resulting argument is longer than MAXPATHLEN, realloc() was called to
extend the space, but the new pointer was not correctly stored.

Different from what OpenBSD has done, rewrite brace_subst() to calculate the
necessary space first and realloc() at most once.

As before, the e_len fields are not updated in case of a realloc.
Therefore, a following long argument will do another realloc.

PR: 201750

git-svn-id: svn://svn.freebsd.org/base/stable/10@287266 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.bin/find/extern.h
usr.bin/find/misc.c