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 759224 - illegal dates in stock transactions cause corrupt file
illegal dates in stock transactions cause corrupt file
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Currency and Commodity
2.6.9
Other FreeBSD
: Normal normal
: ---
Assigned To: gnucash-core-maint
gnucash-core-maint
Depends on:
Blocks:
 
 
Reported: 2015-12-09 04:31 UTC by Graham Menhennitt
Modified: 2018-06-29 23:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
corrupt file (1.34 KB, text/gzip)
2015-12-09 04:31 UTC, Graham Menhennitt
  Details
trace output (571 bytes, text/plain)
2015-12-09 04:32 UTC, Graham Menhennitt
  Details
log of creating corrupt file (1021 bytes, text/plain)
2015-12-09 04:33 UTC, Graham Menhennitt
  Details
Replace string_to_timespec_secs guts with gnc_is08601_to_timespec_gmt() call. (2.66 KB, patch)
2015-12-10 17:59 UTC, John Ralls
none Details | Review

Description Graham Menhennitt 2015-12-09 04:31:54 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.
Comment 1 Graham Menhennitt 2015-12-09 04:32:34 UTC
Created attachment 317001 [details]
trace output
Comment 2 Graham Menhennitt 2015-12-09 04:33:15 UTC
Created attachment 317002 [details]
log of creating corrupt file
Comment 3 John Ralls 2015-12-10 17:59:53 UTC
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.
Comment 4 Geert Janssens 2016-09-14 08:13:35 UTC
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.
Comment 5 Graham Menhennitt 2016-09-15 09:28:19 UTC
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!
Comment 6 Geert Janssens 2016-09-15 10:13:58 UTC
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!
Comment 7 John Ralls 2018-06-29 23:44:48 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=759224. Please update any external references or bookmarks.