libgsf r1045 - in trunk: . gsf



Author: jody
Date: Thu Feb 19 10:39:40 2009
New Revision: 1045
URL: http://svn.gnome.org/viewvc/libgsf?rev=1045&view=rev

Log:
2009-02-18  Jody Goldberg <jody gnome org>

	* gsf/gsf-infile-msole.c (gsf_infile_msole_new_child) : Handle
	  small-block files that are not block aligned. [#572290]


Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/gsf/gsf-infile-msole.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Thu Feb 19 10:39:40 2009
@@ -5,6 +5,11 @@
 	  documentation generation in some environments.
 	  [http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39015]
 
+Jody :
+	* Handle small-block files that are not block aligned. [#572290]
+	* Deprecate gsf_timestamp_parse and replace it with gsf_timestamp_from_string.
+	* Gtk-Doc fixes.
+
 Morten:
 	* Handle malformed xml better.  [#568994]
 	* Drop characters that xml 1.0 cannot represent.  [#568919]

Modified: trunk/gsf/gsf-infile-msole.c
==============================================================================
--- trunk/gsf/gsf-infile-msole.c	(original)
+++ trunk/gsf/gsf-infile-msole.c	Thu Feb 19 10:39:40 2009
@@ -795,26 +795,34 @@
 	}
 
 	if (dirent->use_sb) {
-		unsigned i;
+		unsigned int i;
+		int remaining;
 		guint8 const *data;
 
 		g_return_val_if_fail (sb_file != NULL, NULL);
 
-		child->stream.buf_size = info->threshold;
-		child->stream.buf = g_new (guint8, info->threshold);
+		child->stream.buf_size = remaining = dirent->size;
+		child->stream.buf = g_new (guint8, child->stream.buf_size);
 
-		for (i = 0 ; i < child->bat.num_blocks; i++)
+		for (i = 0 ; remaining > 0 && i < child->bat.num_blocks; i++, remaining -= info->sb.size)
 			if (gsf_input_seek (GSF_INPUT (sb_file),
 				(gsf_off_t)(child->bat.block [i] << info->sb.shift), G_SEEK_SET) < 0 ||
 			    (data = gsf_input_read (GSF_INPUT (sb_file),
-				info->sb.size, 
+				((unsigned int)remaining > info->sb.size) ? info->sb.size : remaining, 
 				child->stream.buf + (i << info->sb.shift))) == NULL) {
 
-				g_warning ("failure reading block %d", i);
-
+				g_warning ("failure reading block %d for '%s'", i, dirent->name);
+				if (err) *err = g_error_new (gsf_input_error_id (), 0, "failure reading block");
 				g_object_unref (G_OBJECT (child));
 				return NULL;
 			}
+
+		if (remaining > 0) {
+			if (err) *err = g_error_new (gsf_input_error_id (), 0, "insufficient blocks");
+			g_warning ("Small-block file '%s' has insufficient blocks (%u) for the stated size (%u)", dirent->name, child->bat.num_blocks, dirent->size);
+			g_object_unref (G_OBJECT (child));
+			return NULL;
+		}
 	}
 
 	return GSF_INPUT (child);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]