mirror of
https://github.com/samba-team/samba.git
synced 2025-01-26 10:04:02 +03:00
util/charset/convert: do not overflow dest len
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
09355b7855
commit
265b3b0c6c
@ -349,7 +349,7 @@ bool convert_string_talloc_handle(TALLOC_CTX *ctx, struct smb_iconv_handle *ic,
|
||||
size_t *converted_size)
|
||||
|
||||
{
|
||||
size_t i_len, o_len, destlen = (srclen * 3) / 2;
|
||||
size_t i_len, o_len, destlen;
|
||||
size_t retval;
|
||||
const char *inbuf = (const char *)src;
|
||||
char *outbuf = NULL, *ob = NULL;
|
||||
@ -397,6 +397,15 @@ bool convert_string_talloc_handle(TALLOC_CTX *ctx, struct smb_iconv_handle *ic,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (srclen >= SIZE_MAX / 3) {
|
||||
DBG_ERR("convert_string_talloc: "
|
||||
"srclen is %zu, destlen would wrap!\n",
|
||||
srclen);
|
||||
errno = EOPNOTSUPP;
|
||||
return false;
|
||||
}
|
||||
destlen = srclen * 3 / 2;
|
||||
|
||||
convert:
|
||||
|
||||
/* +2 is for ucs2 null termination. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user