ldb-samba: ldif_read_objectSid avoids VLA master
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Sat, 4 May 2024 01:40:35 +0000 (13:40 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 8 May 2024 00:26:42 +0000 (00:26 +0000)
I don't think this variable length array is any trouble, but people
complain about them (e.g. https://nullprogram.com/blog/2019/10/27/)
because they make things more complex at run-time, and this is a
somewhat performance sensitive path.

DOM_SID_STR_BUFLEN + 1 is 191 -- if that stack allocation is going to
cause trouble, then so was the VLA <= that.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed May  8 00:26:42 UTC 2024 on atb-devel-224

lib/ldb-samba/ldif_handlers.c

index 458811f2207a49b00f6d42dadabd81fb6f8d7ff3..355312226111d278979f7ed7966beae6bc556987 100644 (file)
@@ -98,7 +98,7 @@ static int ldif_read_objectSid(struct ldb_context *ldb, void *mem_ctx,
        if (in->data[0] != 'S' && in->data[0] != 's') {
                return -1;
        } else {
-               char p[in->length+1];
+               char p[DOM_SID_STR_BUFLEN + 1];
                memcpy(p, in->data, in->length);
                p[in->length] = '\0';