GNOME Bugzilla – Bug 502646
Win32: Crash entering dates before 1/1/1970 in dialogs
Last modified: 2018-06-29 21:56:01 UTC
Steps to reproduce: 1. Run a transaction report. 2. Click Options 3. Enter 12/31/1969 for the start date. This bug is not specific to reporting. For example, you can also enter 12/31/1969 in the dialog box that pops up when you go into an account register and pick Action->Schedule from the menu. Stack trace: gdb: kernel event for pid=2844 tid=5360 code=EXCEPTION_DEBUG_EVENT) gdb: Target exception EXCEPTION_ACCESS_VIOLATION at 0x63c29b5c Program received signal SIGSEGV, Segmentation fault. 0x63c29b5c in gnc_date_edit_set_time_tm (gde=0x3c51958, mytm=0x0) at ../../../src/gnome-utils/gnc-date-edit.c:500 500 ../../../src/gnome-utils/gnc-date-edit.c: No such file or directory. in ../../../src/gnome-utils/gnc-date-edit.c (gdb) bt
+ Trace 181312
Other information: It looks like the date entered by the user is not check properly to make sure that it is 1970 or later. If a date before 1/1/1970 is entered, a warning should pop up and the date should return to its prior value. Also, function gnc_date_edit_set_time_tm in gnome-utils/gnc-date-edit.c does not check whether parameter mytm is non-null before using it. This is what causes the segmentation fault.
just wanted to report another use case where this bug could be triggered. this is the gnucash 2.2.4 windows build i downloaded from gnucash.org. my gnucash crashed when i tried to reconcile an account that doesn't have a "gnc_reconcile_last_statement_date" somehow (see gnucash/repos/src/gnome/window-reconcile.c recnWindow()). this is the stacktrace i got:
+ Trace 196035
and the cause seems to be the same as what Charles Day reported, that gnc_date_edit_set_time_tm() does not check if mytm is NULL before dereferencing it. this patch seems to fix the reconcile crash for me, but it doesn't fix the bug that you're not able to specify a time range starting before 1/1/1970. Index: gnc-date-edit.c =================================================================== --- gnc-date-edit.c (revision 17123) +++ gnc-date-edit.c (working copy) @@ -497,6 +497,13 @@ char buffer [40]; /* Set the date */ + if (!mytm) + { + gtk_entry_set_text (GTK_ENTRY (gde->date_entry), ""); + gtk_entry_set_text (GTK_ENTRY (gde->time_entry), ""); + return; + } + qof_print_date_dmy_buff (buffer, 40, mytm->tm_mday, mytm->tm_mon + 1, (also a better fix would be to populate gde->date_entry with the current date...)
Fix committed as r17327. Requesting backport for 2.2. If an invalid date is entered (i.e. a date not supported by time_t) the date now reverts to the last valid date entered or, as a last resort, the beginning of the current day.
Applied to branches/2.2 as r17386 for inclusion in GnuCash 2.2.6. Thanks!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=502646. Please update any external references or bookmarks.