]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libwbclient: fix strict-overflow warning in wbcSidToString()
authorStefan Metzmacher <metze@samba.org>
Wed, 4 Aug 2021 16:03:13 +0000 (18:03 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 30 Nov 2021 15:53:34 +0000 (15:53 +0000)
../../nsswitch/libwbclient/wbc_sid.c:83:5: error: assuming signed overflow does not occur when simplifying conditional [-Werror=strict-overflow]
  if (len+1 > sizeof(buf)) {
     ^

Even this would fail:
../../nsswitch/libwbclient/wbc_sid.c:83:5: error: assuming signed overflow does not occur when simplifying conditional [-Werror=strict-overflow]
  if (len >= sizeof(buf)) {
     ^

Note that this only seems to happen with gcc 7 and when -O3 and
-fvisibility=hidden are used together. E.g. in the opensuse151-samba-o3
builds.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14780

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
nsswitch/libwbclient/wbc_sid.c

index e0b92bd4d3461f7ffc133a96c29a7efa71e2ec86..3dfc0805767c6e3c646b05524df4665d8de2e6d5 100644 (file)
@@ -78,7 +78,7 @@ wbcErr wbcSidToString(const struct wbcDomainSid *sid,
 
        len = wbcSidToStringBuf(sid, buf, sizeof(buf));
 
-       if (len+1 > sizeof(buf)) {
+       if (len >= WBC_SID_STRING_BUFLEN) {
                return WBC_ERR_INVALID_SID;
        }