Exception on invalid timestamp format

Bug #678236 reported by iceman50
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DC++
Confirmed
Low
Unassigned

Bug Description

DC++ rev 2296 (and newer) crash on invalid timestamp format, i.e. put %D in the timestamp format and it instantly crashes

Tags: core
Revision history for this message
iceman50 (bdcdevel) wrote :

this concerns exe's compiled with MSVC *NOT* MinGW

Revision history for this message
Szabolcs Molnár (fleet) wrote :

I can confirm this, using the latest BCDC++ build compiled with MSVC.

Changed in dcplusplus:
status: New → Confirmed
Revision history for this message
Big Muscle (bigmuscle) wrote :

This reminds me that I always wanted to know how to avoid problems when formatting string for functions printf, strftime etc. can be set by users. This bug is one case of it.

Revision history for this message
poy (poy) wrote :

if i remember correctly, the solution to this is to set up an exception handler that doesn't re-throw the exception, using SetUnhandledExceptionFilter: <http://msdn.microsoft.com/en-us/library/ms680634(VS.85).aspx>

Revision history for this message
Big Muscle (bigmuscle) wrote :
Revision history for this message
Steven Sheehy (steven-sheehy) wrote :

Or just use boost::format and handle the caught exception instead of some C or windows specific libraries. We already use boost::format for i18n, why not everything else?

http://live.boost.org/doc/libs/1_34_0/libs/format/doc/format.html#exceptions

Revision history for this message
Jacek Sieka (arnetheduck) wrote :

I'm guessing this is for timestamps (strftime) so boost::format won't work...

geez, that's a thoroughly stupid way of handling an invalid time string - crashing the application...I vote for bigmuscles solution =) specially since it will do the right thing if the format string is bad - set errno and return 0.

iceman50 (bdcdevel)
Changed in dcplusplus:
status: Confirmed → Fix Committed
Revision history for this message
poy (poy) wrote :

still crashes here.

Changed in dcplusplus:
status: Fix Committed → Confirmed
Fredrik Ullner (ullner)
Changed in dcplusplus:
importance: Undecided → Low
Revision history for this message
Fredrik Ullner (ullner) wrote :

Will use the previously mentioned handler, and will be tested when the dialog is closed. When an error occur, it will reset to the previous formatting.

Changed in dcplusplus:
status: Confirmed → In Progress
Revision history for this message
poy (poy) wrote :

this should be done in the formatting function in dcpp::Util, which can throw this on more than just invalid timestamps. it can for example happen with bad parameters in user commands or in log file definitions.

i am reticent in adding this since it only affects a secondary compiler, but can be convinced if the patch is inconspicuous enough.

Fredrik Ullner (ullner)
Changed in dcplusplus:
status: In Progress → Confirmed
Fredrik Ullner (ullner)
tags: added: core
Revision history for this message
iceman50 (bdcdevel) wrote :

When/If VS2015 is supported we should update this to use _set_thread_local_invalid_parameter_handler instead per <https://msdn.microsoft.com/en-us/library/a9yf33zb(v=vs.140).aspx>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.