Exception on invalid timestamp format

Bug #678236 reported by iceman50 on 2010-11-21
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
DC++
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

iceman50 (bdcdevel) wrote :

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

Szabolcs Molnár (fleet) wrote :

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

Changed in dcplusplus:
status: New → Confirmed
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.

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>

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

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) on 2011-04-07
Changed in dcplusplus:
status: Confirmed → Fix Committed
poy (poy) wrote :

still crashes here.

Changed in dcplusplus:
status: Fix Committed → Confirmed
Fredrik Ullner (ullner) on 2013-08-10
Changed in dcplusplus:
importance: Undecided → Low
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
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) on 2013-11-03
Changed in dcplusplus:
status: In Progress → Confirmed
Fredrik Ullner (ullner) on 2013-11-30
tags: added: core
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  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers