From: Douglas Bagnall Date: Sat, 4 May 2024 01:40:35 +0000 (+1200) Subject: ldb-samba: ldif_read_objectSid avoids VLA X-Git-Tag: tdb-1.4.11~809 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9844ac289be3430fd3f72c5e57fa00e012c5d417;p=thirdparty%2Fsamba.git ldb-samba: ldif_read_objectSid avoids VLA 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 Reviewed-by: Andrew Bartlett Autobuild-User(master): Andrew Bartlett Autobuild-Date(master): Wed May 8 00:26:42 UTC 2024 on atb-devel-224 --- diff --git a/lib/ldb-samba/ldif_handlers.c b/lib/ldb-samba/ldif_handlers.c index 458811f2207..35531222611 100644 --- a/lib/ldb-samba/ldif_handlers.c +++ b/lib/ldb-samba/ldif_handlers.c @@ -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';