cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: smb.c:320 warning C6297: Arithmetic overflow

From: Marc Hoersken <info_at_marc-hoersken.de>
Date: Sun, 14 Dec 2014 21:30:02 +0100

On 14.12.2014 21:00 Steve Holme wrote:
> I read the MSDN article for that warning and believe we have to cast to a size_t before the shift happens.
>
> As such, I have performed some testing on large files to make sure I don't break anything. I separated the length out into its own variable so I could trace what was happening and believe the following fixes the issue:
>
> msg_size += sizeof(unsigned short) + ((unsigned char) buf[msg_size]) +
> (((size_t) ((unsigned char) buf[msg_size + 1])) << 8);
>
> Are you able to try it using the code analysis feature - please - to see if you still get the warning?

Yep, just applied this small change and it looks good. The warning is
gone using the code analysis.

Thanks!

Best regards,
Marc
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-14