#294 closed defect (fixed)
EMULATE_SECURE_CRT sprintf_s doesn't match spec
Reported by: | Philip Taylor | Owned by: | |
---|---|---|---|
Priority: | Should Have | Milestone: | |
Component: | Core engine | Keywords: | |
Cc: | Patch: |
Description
secure_crt.cpp emulates sprintf_s, vsprintf_s, swprintf_s, vswprintf_s using the snprintf functions. These have the wrong behaviour when the buffer is too short (based on MSDN's documentation), and ought to be made consistent.
Change History (5)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
I've added code to wipe out the destination if it's too short and have added the above test (which must not run with VC's implementation because it raises an error dialog). Could you please mark the ticket as fixed if that is now the case? :)
comment:3 by , 15 years ago
Why can't we just disable the error dialog in VC? r7097 does that, and seems to work alright, unless I'm missing some problem with that approach. Incidentally, a few of the string tests fail now when they're running on VC, so we should probably fix things to be consistent.
comment:4 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Ooh, good idea! The tests were expecting ERANGE in some cases instead of EINVAL, which is now fixed.
Some test code for what I think is the expected behaviour (except I'm ignoring that it should report parameter errors when the buffer is too short):