[PATCH] KRFCDate::parseDateISO8601() bugfix
Frank Osterfeld
frank.osterfeld at gmx.de
Sun Feb 26 23:31:28 GMT 2006
Hi,
I stumbled over three (IMHO severe) bugs in kdecore/krfcdate, affecting kdelibs from trunk and 3.5 branch:
1) (trunk/3.5 branch)
When passing an invalid string date like e.g. "Thu, 01 Jan 2004 19:48:21 GMT" (valid RFC date string, but not ISO) to
time_t KRFCDate::parseDateISO8601(const QString&)
my test app exits due to a failed assert:
ASSERT failure in QList<T>::operator[]: "index out of range",
file /opt2/kde4/include/QtCore/qlist.h, line 369
This is because string lists splitted from the input string are accessed without checking the list size beforehand.
2) (trunk only)
RFCDate::parseDate(QString()) returns 1 (used for both epoch and epoch+1) instead of 0 (invalid).
3) (3.5 branch only)
RFCDate::parseDate(QString()) crashes.
The attached patch fixes these bugs, returning 0 when passing an empty string to either of the two methods, and avoiding the assert fails by checking the size of the string lists.
Also, the test cases in both trunk and 3.5 branch contain only valid dates, but no invalid ones. I added some invalid cases including the case mentioned above.
I can't find a maintainer of the class, so I send the patch to the list.
Tell me whether it's okay to commit.
Regards,
Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060227/89190dc2/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: krfcdate-bugfix-3.5-branch.diff
Type: text/x-diff
Size: 2086 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060227/89190dc2/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: krfcdate-bugfix-trunk.diff
Type: text/x-diff
Size: 2495 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060227/89190dc2/attachment-0001.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060227/89190dc2/attachment.sig>
More information about the kde-core-devel
mailing list