CVE-2021-20277 ldb/attrib_handlers casefold: stay in bounds
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Tue, 8 Dec 2020 08:32:09 +0000 (21:32 +1300)
committerStefan Metzmacher <metze@samba.org>
Wed, 24 Mar 2021 12:05:32 +0000 (12:05 +0000)
For a string that had N spaces at the beginning, we would
try to move N bytes beyond the end of the string.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14655

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/common/attrib_handlers.c

index 11921ca429c4e0615cf36ef6960cf47e9c3a376d..81a74584bcbb2f1a99d387cd9b3253a3d92692df 100644 (file)
@@ -76,7 +76,7 @@ int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
        
        /* remove leading spaces if any */
        if (*s == ' ') {
-               for (t = s; *s == ' '; s++) ;
+               for (t = s; *s == ' '; s++, l--) ;
 
                /* remove leading spaces by moving down the string */
                memmove(t, s, l);