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