1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-20 22:50:26 +03:00

talloc: Fix size type and checks in _vasprintf_tc

This fixes compilation with -Wstrict-overflow=2

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Andreas Schneider 2018-03-21 11:55:45 +01:00 committed by Ralph Boehme
parent 5c909ea453
commit 4a7eaf909d

View File

@ -2554,7 +2554,8 @@ static struct talloc_chunk *_vasprintf_tc(const void *t,
const char *fmt,
va_list ap)
{
int len;
int vlen;
size_t len;
char *ret;
va_list ap2;
struct talloc_chunk *tc;
@ -2562,9 +2563,13 @@ static struct talloc_chunk *_vasprintf_tc(const void *t,
/* this call looks strange, but it makes it work on older solaris boxes */
va_copy(ap2, ap);
len = vsnprintf(buf, sizeof(buf), fmt, ap2);
vlen = vsnprintf(buf, sizeof(buf), fmt, ap2);
va_end(ap2);
if (unlikely(len < 0)) {
if (unlikely(vlen < 0)) {
return NULL;
}
len = vlen;
if (unlikely(len + 1 < len)) {
return NULL;
}