Don't leak errno E2BIG to callers.

This commit is contained in:
Richard W.M. Jones 2014-11-20 21:41:08 +00:00
parent 7c43fb667d
commit 4604a1d345
2 changed files with 38 additions and 2 deletions

View File

@ -0,0 +1,33 @@
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

View File

@ -7,7 +7,7 @@
Name: hivex
Version: 1.3.11
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Read and write Windows Registry binary hive files
License: LGPLv2
@ -23,6 +23,7 @@ BuildRequires: autoconf, automake, libtool, gettext-devel
Patch1: 0001-lib-write-fix-memory-leak.patch
Patch2: 0002-lib-Increase-HIVEX_MAX_VALUE_LEN-to-8000000.patch
Patch3: 0001-lib-Increase-HIVEX_MAX_SUBKEYS-to-25000.patch
Patch4: 0001-lib-Don-t-leak-errno-from-_hivex_recode-function.patch
BuildRequires: perl
BuildRequires: perl-Test-Simple
@ -166,6 +167,7 @@ autoreconf -i
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%build
%configure
@ -272,8 +274,9 @@ rm $RPM_BUILD_ROOT%{python_sitearch}/libhivexmod.la
%changelog
* Thu Nov 20 2014 Richard W.M. Jones <rjones@redhat.com> - 1.3.11-3
* Thu Nov 20 2014 Richard W.M. Jones <rjones@redhat.com> - 1.3.11-4
- Increase HIVEX_MAX_SUBKEYS.
- Don't leak errno E2BIG to callers.
* Fri Nov 14 2014 Richard W.M. Jones <rjones@redhat.com> - 1.3.11-2
- Pull in a couple of upstream fixes: