[Spice-devel] [vdagent-win PATCH V3 10/11] Fix Visual Studio compiler warning (strcat and sscanf)

Uri Lublin uril at redhat.com
Wed Feb 11 03:10:30 PST 2015


On 01/19/2015 07:03 PM, Christophe Fergeau wrote:
> On Tue, Dec 30, 2014 at 06:20:56PM +0200, Uri Lublin wrote:
>> This is a follow-up to commits 492ee05a6b and 4b9e9b1d28
>>
>> Visual Studio complains:
>>    .\file_xfer.cpp(90) : warning C4996: 'strcat': This function or variable
>>    may be unsafe. Consider using strcat_s instead.
>>    To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
>>    See online help for details.
>>
>> And a similar complain for sscanf.
>>
>> Replace them with the secure function when compiling with Visual Studio.
>> Note that the size provided is sizeof(d), which means all calls to
>> sscanf and strcat must be done with the first param (destination) being
>> an array and not a pointer.
>
> This sounds very wrong (same for the strncpy commit) as this is very
> uncommon behaviour for something called sscanf/strcat/strncpy, and
> this means mingw and visual c++ will behave differently when these
> functions are used.

Hi Christophe,

I agree it may be confusing.
This is why I specifically mentioned it.
All current users are fine, as Marc-Andre's commits log mention, but
new code in the future may get it wrong.

We can change it with a follow-up patch.

Thanks,
     Uri.


More information about the Spice-devel mailing list