GNOME Bugzilla – Bug 759224
illegal dates in stock transactions cause corrupt file
Last modified: 2018-06-29 23:44:48 UTC
Created attachment 317000 [details] corrupt file If a transaction in a Stock account is given an illegal date (e.g. before 1970), the GC file becomes corrupt and can't be opened. Such illegal dates in normal register transactions are corrected to 1970-01-01. The same should happen for Stock transactions. - Create a new GC file - In the Security editor, create a new security - Create a new account of type Stock which uses the new security - Open the new account - Create a new stock transaction with a date of 1899-01-01 - Exit GC saving the file - Start GC => "There was an error parsing the file ..." The corrupt file, the log file from creating it, and the /tmp/gnucash.trace produced are attached. It would be really good if the trace output file gave the line number of the offending line. And the dates suggested to look for in that file are not useful here.
Created attachment 317001 [details] trace output
Created attachment 317002 [details] log of creating corrupt file
Created attachment 317163 [details] [review] Replace string_to_timespec_secs guts with gnc_is08601_to_timespec_gmt() call. Works fine on MacOS X, a FreeBSD decendant: aaa.gnucash loads without complaint and the date is correctly interpreted as 11 Dec 1899. But we can work around the FreeBSD bug by calling gnc_iso8901_to_timespec_gmt(), which does its own sscanf parsing. That has the added benefit of better encapsulation of date behavior. Please test the attached patch.
No reply so far. Graham, are you capable of building your own gnucash with the patch provided by John and report whether this fixes the bug ? Or do you know someone who can ? As we can't reproduce the bug on our own systems, we need confirmation from someone running FreeBSD. Thanks.
Sorry, I never noticed that a patch had been attached here. Anyway, it looks like the first half of that patch has already been applied to 2.6.13 (or earlier). I can confirm that I can now open the corrupt file without error. So, it appears to be fixed. Thank you!
Thanks for the reply. You are right indeed this patch was added to our stable branch. Apparently it went into 2.6.10. Sorry I missed that. I'm happy it fixes your issue!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=759224. Please update any external references or bookmarks.