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 09:06:23 +0000 (09:06 +0000)
commitf9d9ba6cd06aca053c747c399ba700db80b1623c
tree3d487837a889fe21b1be4a0a525b84dda69fc2a1
parent05596094a9b41fd1de417cfd31cfe898e21cd4cf
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