After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 702689 - Crash on a corrupted (fuzzed) gnumeric file
Crash on a corrupted (fuzzed) gnumeric file
Status: RESOLVED FIXED
Product: Gnumeric
Classification: Applications
Component: import/export other
git master
Other Linux
: Normal critical
: ---
Assigned To: Morten Welinder
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2013-06-19 20:33 UTC by jutaky
Modified: 2013-06-20 19:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed patch (option 1) (1.01 KB, patch)
2013-06-20 16:56 UTC, Andreas J. Guelzow
none Details | Review
proposed patch (option 2) (534 bytes, patch)
2013-06-20 16:59 UTC, Andreas J. Guelzow
none Details | Review

Description jutaky 2013-06-19 20:33:05 UTC
Crash on a corrupted (fuzzed) gnumeric file. Trying to open too wide window?

Git versions of glib, goffice, gnumeric, libgsf and libxml2.

Test case: http://jutaky.com/fuzzing/gnumeric_case_11083_3399.gnumeric

(/home/jutaky/fuzzing/apps/bin/gnumeric-1.12.3:19365): Gdk-WARNING **: Native Windows wider or taller than 65535 pixels are not supported

(/home/jutaky/fuzzing/apps/bin/gnumeric-1.12.3:19365): Gdk-ERROR **: The program '/home/jutaky/fuzzing/apps/bin/gnumeric-1.12.3' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadValue (integer parameter out of range for operation)'.
  (Details: serial 210 error_code 2 request_code 12 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff3b52fa5 in g_logv (log_domain=0x7ffff5aa7ae6 "Gdk", log_level=G_LOG_LEVEL_ERROR, format=0x7ffff5ab3350 "%s", args=0x7fffffffd408) at gmessages.c:989
989			G_BREAKPOINT ();
(gdb) bt
  • #0 g_logv
    at gmessages.c line 989
  • #1 g_log
    at gmessages.c line 1025
  • #2 ??
    from /usr/lib/libgdk-3.so.0
  • #3 ??
    from /usr/lib/libgdk-3.so.0
  • #4 _XError
    from /usr/lib/libX11.so.6
  • #5 ??
    from /usr/lib/libX11.so.6
  • #6 ??
    from /usr/lib/libX11.so.6
  • #7 _XReply
    from /usr/lib/libX11.so.6
  • #8 XInternAtom
    from /usr/lib/libX11.so.6
  • #9 gdk_x11_atom_to_xatom_for_display
    from /usr/lib/libgdk-3.so.0
  • #10 gdk_x11_window_set_utf8_property
    from /usr/lib/libgdk-3.so.0
  • #11 ??
    from /usr/lib/libgtk-3.so.0
  • #12 ??
    from /usr/lib/libgtk-3.so.0
  • #13 g_cclosure_marshal_VOID__VOIDv
    at gmarshal.c line 115
  • #14 g_type_class_meta_marshalv
    at gclosure.c line 997
  • #15 _g_closure_invoke_va
    at gclosure.c line 840
  • #16 g_signal_emit_valist
    at gsignal.c line 3234
  • #17 g_signal_emit
    at gsignal.c line 3382
  • #18 gtk_widget_map
    from /usr/lib/libgtk-3.so.0
  • #19 ??
    from /usr/lib/libgtk-3.so.0
  • #20 g_cclosure_marshal_VOID__VOID
    at gmarshal.c line 85
  • #21 g_type_class_meta_marshal
    at gclosure.c line 970
  • #22 g_closure_invoke
    at gclosure.c line 777
  • #23 signal_emit_unlocked_R
    at gsignal.c line 3512
  • #24 g_signal_emit_valist
    at gsignal.c line 3326
  • #25 g_signal_emit
    at gsignal.c line 3382
  • #26 gtk_widget_show
    from /usr/lib/libgtk-3.so.0
  • #27 show_gui
    at wbc-gtk.c line 2527
  • #28 g_idle_dispatch
    at gmain.c line 5235
  • #29 g_main_dispatch
    at gmain.c line 3058
  • #30 g_main_context_dispatch
    at gmain.c line 3634
  • #31 g_main_context_iterate
    at gmain.c line 3705
  • #32 g_main_context_iteration
    at gmain.c line 3766
  • #33 gtk_main_iteration_do
    from /usr/lib/libgtk-3.so.0
  • #34 handle_paint_events
    at main-application.c line 115
  • #35 main
    at main-application.c line 346

--
Juha Kylmänen
Research Assistant, OUSPG
Comment 1 Morten Welinder 2013-06-20 02:38:05 UTC
There's a gtk+ bug for this somewhere.  65535 should have been 32767.
The fix is obvious, but somehow doesn't get applied.
Comment 2 Andreas J. Guelzow 2013-06-20 07:23:50 UTC
Okay, I don't see a crash. I note that there are criticals if the file is opened as a second (or later file). In that case teh window is empty and I see:

(gnumeric:12947): Gdk-WARNING **: Native Windows wider or taller than 65535 pixels are not supported

(gnumeric:12947): Gtk-CRITICAL **: gtk_distribute_natural_allocation: assertion `extra_space >= 0' failed
Comment 3 Andreas J. Guelzow 2013-06-20 07:28:51 UTC
All of this should be caused by
  <gmr:Geometry Width="65536" Height="544"/>
Comment 4 Andreas J. Guelzow 2013-06-20 08:30:23 UTC
The following will fix the issue at hand:
----------------------------------------------
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index fbf60ff..5a1d36e 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -601,6 +601,11 @@ xml_sax_wb_view (GsfXMLIn *xin, xmlChar const **attrs)
                else
                        unknown_attr (xin, attrs);
 
+       if (width > 2000)
+               width = 2000;
+       if (height > 2000)
+               height = 2000;
+
        if (width > 0 && height > 0)
                wb_view_preferred_size (state->wb_view, width, height);
 }
----------------------------------------------

but we really should use a number closer to the true screen size.
Comment 5 Morten Welinder 2013-06-20 13:44:27 UTC
I don't like it in that location.

The place to truncate would be wbc-gtk.c, near line 2487.  I think we even
have a display/screen to query at that point.
Comment 6 Morten Welinder 2013-06-20 14:23:12 UTC
Gtk gtk+ bug is bug 698758.  (With many duplicates.)
Comment 7 Andreas J. Guelzow 2013-06-20 16:56:40 UTC
Created attachment 247358 [details] [review]
proposed patch (option 1)

This patch limits the preferred size to the total screen size.
Comment 8 Andreas J. Guelzow 2013-06-20 16:59:55 UTC
Created attachment 247359 [details] [review]
proposed patch (option 2)

This patch limits the preferred size to the monitor size (enlarged to 600 by 200). 

In view of the maximization code that follows both options 1 and 2 have the same effect. I prefer option 1 because I don't think the current maximization code makes sense. The maximization code makes it impossible to save and restore a window that spans 2 monitors.
Comment 9 Morten Welinder 2013-06-20 18:25:18 UTC
Flip a coin.
Comment 10 Andreas J. Guelzow 2013-06-20 19:38:09 UTC
Head (that's option 1)

This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.