re: strscpy
matthew green <[email protected]> Sat, 30 May 2020 04:36:52 +1000
| Newsgroups | gmane.os.netbsd.devel.security |
|---|---|
| Message-ID | <[email protected]> |
> >> I would want to keep the difference minimal between the two. I think > >> that the > >> version that returns -1 is nice and addresses the concern. What do you > >> think? > > > > Personally I have got no strong opinion. I would change "size > INT_MAX" > > to "size > SSIZE_MAX". > > > > Returning -1 instead of -EINVAL and -E2BIG is good, as there few users > > who check return value at all, and if so, they check whether it is less > > than 0. > > I have updated my patch: > > https://m00nbsd.net/garbage/libkern/strscpy.diff > > We simply return -1. Will commit soon unless there is valid objection. i strongly object. please don't commit more dual-return value APIs. kre's point about it is 100% valid. they're extremely dangerous. i spent a couple of months tracking down a mismatch between linux and netbsd errno values that happens because linux APIs regularly return "-errno", and we (bsd generally, not just netbsd) have avoided that idiom in most places by design. .mrg.