]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
find: Fix segfault with very long path in -exec/-ok ... {} \;.
authorjilles <jilles@FreeBSD.org>
Wed, 5 Aug 2015 21:33:30 +0000 (21:33 +0000)
committerjilles <jilles@FreeBSD.org>
Wed, 5 Aug 2015 21:33:30 +0000 (21:33 +0000)
commitf78eb5cce25af533d8ed1a03dce08e1cfdd894c2
tree08b3ebc54ab5a750014aa548d13b5f24a564a667
parent5f52dff95ea8793cd2f43138a882afdf4db94af8
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
MFC after: 1 week
usr.bin/find/extern.h
usr.bin/find/misc.c