Wireshark mailing list archives
Re: size_t under Windows ...
From: Guy Harris <guy () alum mit edu>
Date: Fri, 24 Nov 2017 11:52:29 -0800
On Nov 23, 2017, at 2:12 PM, Richard Sharpe <realrichardsharpe () gmail com> wrote:
I am running into problems with this in my latest build: #if defined(_WIN32) char * cap_pipe_buf; /**< Pointer to the buffer we read into */ DWORD cap_pipe_bytes_to_read; /**< Used by pipe_dispatch */ DWORD cap_pipe_bytes_read; /**< Used by pipe_dispatch */
On Windows, we read from a pipe with ReadFile(), the byte count argument to which is a DWORD, and the "bytes I actually read" argument to which is a pointer to a DWORD.
#else size_t cap_pipe_bytes_to_read; /**< Used by pipe_dispatch */ size_t cap_pipe_bytes_read; /**< Used by pipe_dispatch */
On UN*X, we read from a pipe with cap_pipe_read(), which calls ws_read(), which is just a #define for read on UN*X; the byte count argument to read() is a size_t, and the "bytes I actually read, or -1 for error" return value for which is an ssize_t. What are the problems that this causes? Perhaps we should simply restrict the number of bytes to be read in any one call to INT_MAX, which should fit in a DWORD, a size_t, or an ssize_t, and thus work on Windows and UN*X, either 32-bit or 64-bit, and declare both cap_pipe_bytes_to_read and cap_pipe_bytes_read to be int. ___________________________________________________________________________ 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)