From e5452a37425484a95f90604a3e58e8a731460793 Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Wed, 31 Jul 2019 01:08:23 +0000 Subject: [PATCH] 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 --- source3/lib/tldap_util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; }