34 lines
1.0 KiB
Diff
34 lines
1.0 KiB
Diff
|
From 4b3c3cd2b3d8d34601979feeb1390fddd442ab04 Mon Sep 17 00:00:00 2001
|
||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||
|
Date: Thu, 20 Nov 2014 21:37:19 +0000
|
||
|
Subject: [PATCH] lib: Don't leak errno from _hivex_recode function.
|
||
|
|
||
|
If iconv returns E2BIG, that's an internal indication for us, and not
|
||
|
an error. Don't leak the errno up to the user, as happened here:
|
||
|
|
||
|
https://www.redhat.com/archives/libguestfs/2014-November/msg00140.html
|
||
|
|
||
|
Thanks Nicolas Ecarnot.
|
||
|
---
|
||
|
lib/utf16.c | 4 ++++
|
||
|
1 file changed, 4 insertions(+)
|
||
|
|
||
|
diff --git a/lib/utf16.c b/lib/utf16.c
|
||
|
index fe2c3bd..238f40a 100644
|
||
|
--- a/lib/utf16.c
|
||
|
+++ b/lib/utf16.c
|
||
|
@@ -58,6 +58,10 @@ _hivex_recode (const char *input_encoding, const char *input, size_t input_len,
|
||
|
if (r == (size_t) -1) {
|
||
|
if (errno == E2BIG) {
|
||
|
int err = errno;
|
||
|
+ /* Reset errno here because we don't want to accidentally
|
||
|
+ * return E2BIG to a library caller.
|
||
|
+ */
|
||
|
+ errno = 0;
|
||
|
size_t prev = outalloc;
|
||
|
/* Try again with a larger output buffer. */
|
||
|
free (out);
|
||
|
--
|
||
|
2.1.0
|
||
|
|