tech-security archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

re: strscpy



> >> 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.


Home | Main Index | Thread Index | Old Index