On Nov 23, 2017, at 2:12 PM, Richard Sharpe <[email protected]> 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 <[email protected]>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:[email protected]?subject=unsubscribe

Reply via email to