From: Garming Sam Date: Wed, 31 Jul 2019 01:08:23 +0000 (+0000) Subject: tldap: Make memcpy of no controls safe X-Git-Tag: tdb-1.4.2~387 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5452a37425484a95f90604a3e58e8a731460793;p=thirdparty%2Fsamba.git tldap: Make memcpy of no controls safe Static analyzers sometimes complain about this case. Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett BUG: https://bugzilla.samba.org/show_bug.cgi?id=14029 --- diff --git a/source3/lib/tldap_util.c b/source3/lib/tldap_util.c index 152942dab2c..bdf8eb031a5 100644 --- a/source3/lib/tldap_util.c +++ b/source3/lib/tldap_util.c @@ -588,7 +588,9 @@ struct tldap_control *tldap_add_control(TALLOC_CTX *mem_ctx, if (result == NULL) { return NULL; } - memcpy(result, ctrls, sizeof(struct tldap_control) * num_ctrls); + if (num_ctrls > 0) { + memcpy(result, ctrls, sizeof(struct tldap_control) * num_ctrls); + } result[num_ctrls] = *ctrl; return result; }