VS2012: strftime crash with %z formatting code - by Fuxi

Status : 

  Duplicate<br /><br />
		This item appears to be a duplicate of another existing Connect or internal item.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 759720 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 8/27/2012 4:23:47 AM
Access Restriction Public


Calling strftime() with the %z formatting code to get the time-zone name incorrectly invokes the invalid parameter handler (and so terminates the process) when the output buffer is not big enough to fit the complete time-zone name.

Examining the crt source, in VC9/VC10 it does:
_store_str(_tzname[((timeptr->tm_isdst)?1:0)], string, left);

While in VC11 it does:
_ERRCHECK(_mbstowcs_s_l(&wnum, *string, *left, _tzname[((timeptr->tm_isdst)?1:0)], _TRUNCATE, plocinfo));

Because of _TRUNCATE, _mbstowcs_s_l returns STRUNCATE and the invoke_watson... is called through the _ERRCHECK macro.

Remark: it is not really a blocking issue, but due to this, we cannot switch to VS2012 either.
Sign in to post a comment.
Posted by James [MSFT] on 5/27/2013 at 9:32 PM

This bug was separately reported in another Connect issue: #782889, "strftime() crash when the size is not enough in some case" (http://connect.microsoft.com/VisualStudio/feedback/details/782889/). We have in fact fixed this issue for the next release of the Visual C++ libraries. Please see my comments to that issue for further information.

James McNellis
Visual C++ Libraries
Posted by James [MSFT] on 12/17/2012 at 3:50 PM

This is indeed a bug in the runtime libraries. Unfortunately, due to resource constraints, we will be unable to fix this bug for the next release of Visual Studio. We will, however, keep this bug active in our bug database and consider fixing it for a future release.

Note: Connect doesn't notify me about comments. If you have any further questions, please e-mail me.

James McNellis
Visual C++ Libraries
Posted by Microsoft on 8/28/2012 at 6:50 PM
Thanks for your cooperate and patience.

Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Fuxi on 8/28/2012 at 4:05 AM
I already included the program in the "Steps to reproduce" section. However, I just uploaded a sample project as well (I got an error the first time, so it may have been uploaded twice).
Posted by Microsoft on 8/28/2012 at 3:46 AM
Thanks for your feedback.

In order to fix the issue, we must first reproduce the issue in our labs. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project so that we can conduct further research?

Please submit this information to us within 3 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Helen [MSFT] on 8/27/2012 at 11:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)