Re: Type mismatches in safe_read and friends?
From: Rogan Dawes <hidden>
Date: 2016-06-15 22:43:01
Shawn O. Pearce wrote:
quoted
Or is it just a case that we don't really care, since we control the ranges of the values, and the underlying types are int anyway? Patches to follow if I get an indication that anyone cares, otherwise I'd be posting my question to a C newbies group. ;-)It is sort of a case we don't care. These probably should be fixed. A patch would be nice. You want to learn C... ;-)
Ok. So I did a little patch, but I'm not sure whether I solved anything. Now we have an implicit cast from size_t to ssize_t in packet_read_line. I guess this echoes your comment about requesting a large size_t, and getting a ssize_t result back. I suppose in theory we should be refusing to handle a length greater than that which would fit into a ssize_t? Or simply making sure to always return data smaller than max(ssize_t)? Patch to follow. Rogan