[libgsf] Fix gsf_vba_inflate for short streams
- From: Valek Frob <frob src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] Fix gsf_vba_inflate for short streams
- Date: Sat, 19 Jan 2013 21:27:26 +0000 (UTC)
commit 789435807e2375033a4cdf15d6679192a56e63e3
Author: Valek Filippov <frob df ru>
Date: Sat Jan 19 16:24:00 2013 -0500
Fix gsf_vba_inflate for short streams
ChangeLog | 4 ++++
gsf/gsf-infile-msvba.c | 26 +++++++++++++++-----------
2 files changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 69a8331..24109f8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-01-19 Valek Filippov <frob df ru>
+
+ * gsf/gsf-infile-msvba.c,.h (gsf_vba_inflate): Fix for short streams.
+
2013-01-15 Jean Brefort <jean brefort normalesup org>
* configure.ac: renamed configure.in and update obsolete macros.
diff --git a/gsf/gsf-infile-msvba.c b/gsf/gsf-infile-msvba.c
index 4c7bbf2..5256120 100644
--- a/gsf/gsf-infile-msvba.c
+++ b/gsf/gsf-infile-msvba.c
@@ -95,28 +95,32 @@ gsf_vba_inflate (GsfInput *input, gsf_off_t offset, int *size, gboolean add_null
chunk_hdr = GSF_LE_GET_GUINT16 (tmp);
offset += 2;
- if (0xB000 == (chunk_hdr&0xF000) && (chunk_hdr&0xFFF) > 0 && (length - offset < 4096)){
- if (gsf_input_size (input) < offset + (chunk_hdr&0xFFF))
+ if (0xB000 == (chunk_hdr&0xF000) && (chunk_hdr&0xFFF) > 0 && (length - offset < 4094)){
+ if (length < offset + (chunk_hdr&0xFFF))
break;
- chunk = gsf_input_proxy_new_section (input, offset, (gsf_off_t) (chunk_hdr&0xFFF));
- offset += (chunk_hdr&0xFFF);
+ chunk = gsf_input_proxy_new_section (input, offset, (gsf_off_t) (chunk_hdr&0xFFF) + 1);
+ offset += (chunk_hdr&0xFFF) + 1;
} else {
- if (gsf_input_size (input) < offset + 4094)
- break;
- chunk = gsf_input_proxy_new_section (input, offset, 4094);
- offset += 4094;
+ if (length < offset + 4094){
+ chunk = gsf_input_proxy_new_section (input, offset, length-offset);
+ offset = length;
+ } else {
+ chunk = gsf_input_proxy_new_section (input, offset, 4094);
+ offset += 4094;
+ }
}
tmpres = gsf_msole_inflate (chunk,0);
gsf_input_seek (input,offset,G_SEEK_CUR);
g_byte_array_append (res, tmpres->data, tmpres->len);
g_byte_array_free (tmpres, FALSE);
}
-
+
if (res == NULL)
return NULL;
- *size = res->len;
if (add_null_terminator)
g_byte_array_append (res, "", 1);
+ *size = res->len;
+
return g_byte_array_free (res, FALSE);
}
@@ -132,8 +136,8 @@ vba_extract_module_source (GsfInfileMSVBA *vba, char const *name, guint32 src_of
module = gsf_infile_child_by_name (vba->source, name);
if (module == NULL)
return;
-
code = gsf_vba_inflate (module, (gsf_off_t) src_offset, &inflated_size, FALSE);
+
if (code != NULL) {
if (NULL == vba->modules)
vba->modules = g_hash_table_new_full (g_str_hash, g_str_equal,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]