util: Simplify input validation
authorMartin Schwenke <martin@meltin.net>
Tue, 9 Jun 2020 01:52:50 +0000 (11:52 +1000)
committerKarolin Seeger <kseeger@samba.org>
Mon, 6 Jul 2020 13:57:23 +0000 (13:57 +0000)
commitcf319e099c1dc6683864486bd86b44750b0e0b3e
treeb801f388c3c55f6abce6a13f4fdf09bc57351767
parent671e06eb4965840c05fb98a18623c78df096ac39
util: Simplify input validation

It appears that snprintf(3) is being used for input validation.
However, this seems like overkill because it causes szPath to be
copied an extra time.  The mostly likely protections being sought
here, according to https://cwe.mitre.org/data/definitions/20.html,
look to be DoS attacks involving CPU and memory usage.  A simpler
check that uses strnlen(3) can mitigate against both of these and is
simpler.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Bjoern Jacke <bjacke@samba.org>
(cherry picked from commit 922bce2668994dd2a5988c17060f977e9bb0c229)
lib/util/util_paths.c