[PATCH] Introduce dom_sid_str_buf

Jeremy Allison jra at samba.org
Thu Nov 1 17:23:44 UTC 2018


On Thu, Nov 01, 2018 at 11:29:24AM +0100, Volker Lendecke wrote:
> On Tue, Oct 30, 2018 at 05:06:36PM -0700, Jeremy Allison wrote:
> > I really like this, but the error return checking on dom_sid_string_buf()
> > isn't correct here (having said that, dom_sid_string_buf() is a
> > *horribly* designed interface, it should take and return a size_t,
> > not an int).
> 
> It was modeled after
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
> 
> which has "int" as a return value for snprintf. This of course we
> ignore(d) completely.

What a surprise :-).

> Attached find two patches supposed to fix this.
> Review appreciated!

The first patch is correct, but the first patch isn't quite
complete. Although we ignore the return from dom_sid_string_buf()
in most places there are two existing places we check the
return, so these also need updating to cope with a -1 return.

Additional patch attached. Feel free to squash this with
the first patch.

For the second patch:

+       ret = dom_sid_string_buf(sid, dst->buf, sizeof(dst->buf));
+       if ((ret < 0) > (ret >= sizeof(dst->buf))) {

the error check doesn't look right to me. Shouldn't it be:

+       if ((ret < 0) || (ret >= sizeof(dst->buf))) {

?

Cheers,

Jeremy.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-SQUASH-Fixup-existing-error-checks-for-dom_sid_strin.patch
Type: text/x-diff
Size: 1379 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20181101/47d41b3b/0001-SQUASH-Fixup-existing-error-checks-for-dom_sid_strin.diff>


More information about the samba-technical mailing list