cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Steve Holme <steve_holme_at_hotmail.com>
Date: Sun, 14 Dec 2014 20:00:39 +0000

On Sun, 14 Dec 2014, Marc Hoersken wrote:

> > Is there anything I can enable in the generated project files to see what
> > you're seeing?
>
> I used the code analysis feature of Visual Studio Premium 2012 and ran it
> against the whole solution.

Ah - I'm not using the Premium version :(

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?

Cheers

Steve

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