From: Douglas Bagnall Date: Thu, 22 Mar 2018 04:54:55 +0000 (+1300) Subject: util/charset/iconv: use read_hex_bytes rather than sscanf X-Git-Tag: tevent-0.9.37~463 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2157e8d83e7d32e646e7054d969d6be59053378b;p=thirdparty%2Fsamba.git util/charset/iconv: use read_hex_bytes rather than sscanf Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/lib/util/charset/iconv.c b/lib/util/charset/iconv.c index 02c061ccd09..a03ff20b8cc 100644 --- a/lib/util/charset/iconv.c +++ b/lib/util/charset/iconv.c @@ -25,6 +25,8 @@ #include "lib/util/dlinklist.h" #include "lib/util/charset/charset.h" #include "lib/util/charset/charset_proto.h" +#include "libcli/util/ntstatus.h" +#include "lib/util/util_str_hex.h" #ifdef strcasecmp #undef strcasecmp @@ -454,8 +456,8 @@ static size_t ucs2hex_pull(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) { while (*inbytesleft >= 1 && *outbytesleft >= 2) { - unsigned int v; - + uint64_t v; + NTSTATUS status; if ((*inbuf)[0] != '@') { /* seven bit ascii case */ (*outbuf)[0] = (*inbuf)[0]; @@ -471,8 +473,9 @@ static size_t ucs2hex_pull(void *cd, const char **inbuf, size_t *inbytesleft, errno = EINVAL; return -1; } + status = read_hex_bytes(&(*inbuf)[1], 4, &v); - if (sscanf(&(*inbuf)[1], "%04x", &v) != 1) { + if (!NT_STATUS_IS_OK(status)) { errno = EILSEQ; return -1; }