[msitools] libmsi: don't crash on invalid string conversion
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [msitools] libmsi: don't crash on invalid string conversion
- Date: Fri, 8 Nov 2013 13:16:45 +0000 (UTC)
commit e02b155b332df452a9df86984e11eb8a1772aa86
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Fri Nov 8 14:13:39 2013 +0100
libmsi: don't crash on invalid string conversion
SSIA, TODO: check if "forcecodepage" is used correctly.
https://bugzilla.redhat.com/show_bug.cgi?id=1027256
libmsi/string.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/libmsi/string.c b/libmsi/string.c
index 9514d46..0dfa003 100644
--- a/libmsi/string.c
+++ b/libmsi/string.c
@@ -200,6 +200,8 @@ static void insert_string_sorted( string_table *st, unsigned string_id )
static void set_st_entry( string_table *st, unsigned n, char *str, uint16_t refcount, enum StringPersistence
persistence )
{
+ g_return_if_fail(str != NULL);
+
if (persistence == StringPersistent)
{
st->strings[n].persistent_refcount = refcount;
@@ -253,6 +255,7 @@ static int msi_addstring( string_table *st, unsigned n, const char *data, int le
size_t sz;
int codepage;
GIConv cpconv;
+ GError *err = NULL;
if( !data )
return 0;
@@ -288,10 +291,14 @@ static int msi_addstring( string_table *st, unsigned n, const char *data, int le
/* allocate a new string */
codepage = st->codepage ? st->codepage : gsf_msole_iconv_win_codepage();
cpconv = gsf_msole_iconv_open_for_import(codepage);
- str = g_convert_with_iconv(data, len, cpconv, NULL, &sz, NULL);
+ str = g_convert_with_iconv(data, len, cpconv, NULL, &sz, &err);
g_iconv_close(cpconv);
-
- set_st_entry( st, n, str, refcount, persistence );
+ if (err) {
+ g_warning("iconv failed: %s", err->message);
+ g_clear_error(&err);
+ } else {
+ set_st_entry( st, n, str, refcount, persistence);
+ }
return n;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]