Wireshark mailing list archives
Re: size_t under Windows ...
From: Guy Harris <guy () alum mit edu>
Date: Fri, 24 Nov 2017 12:11:29 -0800
On Nov 24, 2017, at 12:03 PM, Richard Sharpe <realrichardsharpe () gmail com> wrote:
110>C:\buildbot\builders\windows-x86-64-petri-dish\windows-x86-64-petri-dish\build\dumpcap.c(2425): warning C4267: '=': conversion from 'size_t' to 'DWORD', possible loss of data which seems to be cause by: pcap_src->cap_pipe_bytes_to_read = hdrsize; and hdrsize is defined as size_t, so there is possible loss of range on Windows.
If hdrsize is larger than the largest possible DWORD value, the loss of range is not only possible, it's certain. If hdrsize can be guaranteed not to be larger than the largest possible DWORD value, you can safely cast it to DWORD.
hdrsize is set from a sizeof
Then perhaps it should be declared to be a DWORD on Windows. Or perhaps we should just go with int, which should work on *all* platforms. That does, however, mean that we need to handle reading packets with pcap, or blocks with pcapng, with a size > INT_MAX. But we should *always* have been doing that, so as not to be tripped up by files, whether maliciously constructed or not, with records bigger than we're willing to handle. ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev () wireshark org> Archives: https://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-request () wireshark org?subject=unsubscribe
Current thread:
- size_t under Windows ... Richard Sharpe (Nov 23)
- Re: size_t under Windows ... Helge Kruse (Nov 24)
- Re: size_t under Windows ... Dario Lombardo (Nov 24)
- Re: size_t under Windows ... Roland Knall (Nov 24)
- Re: size_t under Windows ... Graham Bloice (Nov 24)
- Re: size_t under Windows ... Dario Lombardo (Nov 24)
- Re: size_t under Windows ... Helge Kruse (Nov 24)
- Re: size_t under Windows ... Guy Harris (Nov 24)
- Re: size_t under Windows ... Richard Sharpe (Nov 24)
- Re: size_t under Windows ... Guy Harris (Nov 24)
- Re: size_t under Windows ... Richard Sharpe (Nov 24)