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 571447 - libofx (external) crashes on invalid date format in DTSTART/DTEND
libofx (external) crashes on invalid date format in DTSTART/DTEND
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Import - OFX
2.2.x
Other All
: Normal critical
: ---
Assigned To: Benoit Grégoire
Benoit Grégoire
: 612135 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-02-12 12:46 UTC by Andy
Modified: 2018-06-29 22:17 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andy 2009-02-12 12:46:17 UTC
Steps to reproduce:
1. On Windows Gnucash 2.2.8, create a new empty account system
2. Do File>Import>OFX of an OFX file containing
<BANKTRANLIST><DTSTART>03/11/2008</DTSTART><DTEND>30/11/2008</DTEND>

You get an immediate crash


Here is the entire OFX file

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:NONE
<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>0</CODE><SEVERITY>INFO</SEVERITY></STATUS><DTSERVER></DTSERVER><LANGUAGE>ENG</LANGUAGE><FI><ORG>MyBank</ORG><FID>My Bank</FID></FI></SONRS></SIGNONMSGSRSV1><BANKMSGSRSV1><STMTTRNRS><TRNUID>1</TRNUID><STATUS><CODE>0</CODE><SEVERITY>INFO</SEVERITY></STATUS><STMTRS><CURDEF>EUR</CURDEF><BANKACCTFROM><BANKID>MyBank</BANKID><ACCTID>123-4567890-12</ACCTID><ACCTTYPE>CHECKING</ACCTTYPE></BANKACCTFROM><BANKTRANLIST><DTSTART>03/11/2008</DTSTART><DTEND>30/11/2008</DTEND><STMTTRN><TRNTYPE>DEBIT</TRNTYPE><DTPOSTED>20081128</DTPOSTED><TRNAMT>1234,56</TRNAMT><FITID>0203</FITID><CHECKNUM>0203</CHECKNUM><NAME>John</NAME><MEMO>Some Reason</MEMO></STMTTRN></BANKTRANLIST><LEDGERBAL><BALAMT>+4123,80</BALAMT><DTASOF></DTASOF></LEDGERBAL></STMTRS></STMTTRNRS></BANKMSGSRSV1></OFX>


Stack trace:


Other information:
Note that if you remove the dates from DTSTART and DTEND the crash does not happen.
Comment 1 Phil Longstaff 2009-04-27 21:13:43 UTC
Reproducible on 2.2.9 using the test file above.  Output and stack trace:

LibOFX INFO: libofx_proc_file(): File format not specified, autodecting...
(Above message occured on Line 4294967295, Column 4294967295)             
LibOFX INFO: libofx_proc_file(): Detected file format: OFX (Open Financial eXchange (OFX or QFX))
(Above message occured on Line 4294967295, Column 4294967295)                                    
LibOFX INFO: Created OfxDummyContainer to hold unsupported aggregate SIGNONMSGSRSV1              
(Above message occured on Line 1, Column 6)                                                      
LibOFX INFO: Created OfxDummyContainer to hold unsupported aggregate SONRS                       
(Above message occured on Line 1, Column 22)                                                     
LibOFX INFO: Created OfxDummyContainer to hold unsupported aggregate FI                          
(Above message occured on Line 1, Column 130)                                                    
LibOFX INFO: Created OfxDummyContainer to hold unsupported aggregate BANKMSGSRSV1                
(Above message occured on Line 2, Column 41)                                                     
LibOFX INFO: Created OfxDummyContainer to hold unsupported aggregate STMTTRNRS                   
(Above message occured on Line 2, Column 55)                                                     
terminate called after throwing an instance of 'std::out_of_range'                               
  what():  basic_string::substr                                                                  

Program received signal SIGABRT, Aborted.

Thread 3060070224 (LWP 29243)

  • #0 __kernel_vsyscall
  • #1 raise
    from /lib/tls/i686/cmov/libc.so.6
  • #2 abort
    from /lib/tls/i686/cmov/libc.so.6
  • #3 __gnu_cxx::__verbose_terminate_handler
    from /usr/lib/libstdc++.so.6
  • #4 ??
    from /usr/lib/libstdc++.so.6
  • #5 std::terminate
    from /usr/lib/libstdc++.so.6
  • #6 __cxa_throw
    from /usr/lib/libstdc++.so.6
  • #7 std::__throw_out_of_range
    from /usr/lib/libstdc++.so.6
  • #8 ofxdate_to_time_t
    from /usr/lib/libofx.so.4
  • #9 OfxStatementContainer::add_attribute
    from /usr/lib/libofx.so.4
  • #10 OfxPushUpContainer::add_attribute
    from /usr/lib/libofx.so.4
  • #11 OFXApplication::endElement
    from /usr/lib/libofx.so.4
  • #12 OpenSP::GenericEventHandler::endElement
    from /usr/lib/libosp.so.5
  • #13 OpenSP::Parser::acceptEndTag
    from /usr/lib/libosp.so.5
  • #14 OpenSP::Parser::doContent
    from /usr/lib/libosp.so.5
  • #15 OpenSP::Parser::parseAll
    from /usr/lib/libosp.so.5
  • #16 OpenSP::SgmlParser::parseAll
    from /usr/lib/libosp.so.5
  • #17 OpenSP::ParserApp::parseAll
    from /usr/lib/libosp.so.5
  • #18 OpenSP::ParserEventGenerator::run
    from /usr/lib/libosp.so.5
  • #19 ofx_proc_sgml
    from /usr/lib/libofx.so.4
  • #20 ofx_proc_file
    from /usr/lib/libofx.so.4
  • #21 libofx_proc_file
    from /usr/lib/libofx.so.4
  • #22 gnc_file_ofx_import
    at gnc-ofx-import.c line 693
  • #23 gnc_plugin_ofx_cmd_import
    at gnc-plugin-ofx.c line 145
  • #24 IA__g_cclosure_marshal_VOID__VOID
    at /build/buildd/glib2.0-2.20.1/gobject/gmarshal.c line 77
  • #25 IA__g_closure_invoke
    at /build/buildd/glib2.0-2.20.1/gobject/gclosure.c line 767
  • #26 signal_emit_unlocked_R
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 3247
  • #27 IA__g_signal_emit_valist
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 2980
  • #28 IA__g_signal_emit
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 3037
  • #29 _gtk_action_emit_activate
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkaction.c line 727
  • #30 IA__gtk_action_activate
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkaction.c line 757
  • #31 IA__g_cclosure_marshal_VOID__VOID
    at /build/buildd/glib2.0-2.20.1/gobject/gmarshal.c line 77
  • #32 g_type_class_meta_marshal
    at /build/buildd/glib2.0-2.20.1/gobject/gclosure.c line 878
  • #33 IA__g_closure_invoke
    at /build/buildd/glib2.0-2.20.1/gobject/gclosure.c line 767
  • #34 signal_emit_unlocked_R
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 3177
  • #35 IA__g_signal_emit_valist
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 2980
  • #36 IA__g_signal_emit
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 3037
  • #37 IA__gtk_widget_activate
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkwidget.c line 4792
  • #38 IA__gtk_menu_shell_activate_item
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmenushell.c line 1139
  • #39 gtk_menu_shell_button_release
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmenushell.c line 678
  • #40 gtk_menu_button_release
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmenu.c line 2950
  • #41 _gtk_marshal_BOOLEAN__BOXED
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmarshalers.c line 84
  • #42 g_type_class_meta_marshal
    at /build/buildd/glib2.0-2.20.1/gobject/gclosure.c line 878
  • #43 IA__g_closure_invoke
    at /build/buildd/glib2.0-2.20.1/gobject/gclosure.c line 767
  • #44 signal_emit_unlocked_R
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 3285
  • #45 IA__g_signal_emit_valist
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 2990
  • #46 IA__g_signal_emit
    at /build/buildd/glib2.0-2.20.1/gobject/gsignal.c line 3037
  • #47 gtk_widget_event_internal
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkwidget.c line 4761
  • #48 IA__gtk_propagate_event
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c line 2396
  • #49 IA__gtk_main_do_event
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c line 1601
  • #50 gdk_event_dispatch
    at /build/buildd/gtk+2.0-2.16.1/gdk/x11/gdkevents-x11.c line 2364
  • #51 IA__g_main_context_dispatch
    at /build/buildd/glib2.0-2.20.1/glib/gmain.c line 1814
  • #52 g_main_context_iterate
    at /build/buildd/glib2.0-2.20.1/glib/gmain.c line 2448
  • #53 IA__g_main_loop_run
    at /build/buildd/glib2.0-2.20.1/glib/gmain.c line 2656
  • #54 IA__gtk_main
    at /build/buildd/gtk+2.0-2.16.1/gtk/gtkmain.c line 1205
  • #55 gnc_ui_start_event_loop
    at gnc-gnome-utils.c line 450
  • #56 inner_main
    at gnucash-bin.c line 490
  • #57 scm_boot_guile
    from /usr/lib/libguile.so.12
  • #58 main
    at gnucash-bin.c line 624

Comment 2 Geert Janssens 2010-03-13 11:52:16 UTC
The problem is not a non-empty DTSTART or DTEND tag. The problem is that the values of these tags are in an invalid format.

You can find the proper format on http://www.ofx.net/DownloadPage/Downloads.aspx

DTSTART/DTEND should hold at date in this format:
YYYYMMDDHHMMSS.XXX followed by some optional timezone information
This can be shortened to
YYYYMMSS

But your file contains
MM/DD/YYYY as dateformat.

Did you get this ofx file from your bank or did you (or some program) create these invalid dates ?
Comment 3 Geert Janssens 2010-03-13 18:32:56 UTC
*** Bug 612135 has been marked as a duplicate of this bug. ***
Comment 4 Geert Janssens 2010-03-14 12:04:12 UTC
The duplicate bug 612135 more or less confirms this invalid information comes straight from the bank without any manual editing.

This is unfortunately not a GnuCash bug, but a libofx bug. It was already reported in libofx' bugtracker since 2006:
http://sourceforge.net/tracker/?func=detail&aid=1454059&group_id=61170&atid=496353

Alas, the bug is still there at present. I have added a comment over there that this bug also affects GnuCash users.

Hopefully some libofx developer will pick this up.
Comment 5 Andy 2010-03-21 17:23:49 UTC
The files came directly from Dexia Belgium like that, without manual editing. The example was hand-crafted for privacy reasons.
A dialog message: 'invalid file format' would have been a lot nicer than the crash. I had grown so used to correcting the files that I didn't even notice that my bank made a change in their files. Their change makes Gnucash ompatible with Dexia Belgium. 

For me personally this bug is no longer an issue, although other banks may still be affected. For those, the fact that there is a complete crash is imo the main issue and to be solved on the gnucash/libofx side.
Comment 6 Geert Janssens 2010-08-25 12:03:44 UTC
Some additional information: this bug happens because the ofx standard requires dates to be formatted as YYYYMMDDHHMMSS.XXX[gmt offset:tz name], where the above example uses DD/MM/YYYY. From the bug in libofx' bugtracker it appears several banks around the world tend to use different date formats. And even worse, as the original example shows, in one file several date formats can be mixed.

There's no easy way to have a library universally guess the proper and expected date format in all of these cases. From the libofx bug, it seems to me the libofx maintainers prefer to notify the banks of their wrong use of the ofx standards instead of trying to come up with a complex algorithm that should "magically" parse all these date variants properly. I can't blame them.

But I have added a patch to libofx' bugtracker that should prevent libofx from crashing due to an invalid date format. This patch doesn't attempt to parse the date, but will instead simply print an error message and return the reference date (somewhere in 1970). This is probably not perfect, but the best I can do right now.

Let's hope this will get integrated in libofx very soon.
Comment 7 Geert Janssens 2010-10-26 18:58:16 UTC
My patch got committed to the libofx repository today. The next libofx release will have one opportunity less to crash GnuCash. I don't know when the new release of libofx is to be expected though.
Comment 8 Geert Janssens 2011-02-13 18:42:22 UTC
I notice cstim has released libofx 0.9.2 which should contain my patch. Can this bug be closed in the GnuCash tracker now ?
Comment 9 Christian Stimming 2011-02-13 19:26:44 UTC
I hope so.

I've discovered that I have both libofx CVS write access and also file release priviledges over there, so I can just go ahead and make further releases if we find and fix any bugs in libofx.
Comment 10 Geert Janssens 2011-02-13 20:38:49 UTC
Ok, marked as closed. Should the problem still reappear when using the new libofx, feel free to reopen this bug also.
Comment 11 John Ralls 2018-06-29 22:17:58 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=571447. Please update any external references or bookmarks.