hivex: fail upon integer overflow

* hivex/hivex.c (windows_utf16_to_utf8): Avoid overflow and a
potential infloop.
This commit is contained in:
Jim Meyering
2009-11-03 18:55:21 +01:00
committed by Richard Jones
parent f95c697a44
commit ef642eb4e3

View File

@@ -1033,9 +1033,12 @@ windows_utf16_to_utf8 (/* const */ char *input, size_t len)
size_t r = iconv (ic, &inp, &inlen, &outp, &outlen);
if (r == (size_t) -1) {
if (errno == E2BIG) {
size_t prev = outalloc;
/* Try again with a larger output buffer. */
free (out);
outalloc *= 2;
if (outalloc < prev)
return NULL;
goto again;
}
else {