]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
pylibsmb: avoid unnecessary check of sid/gid counts
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Thu, 6 Mar 2025 23:01:14 +0000 (12:01 +1300)
committerRalph Boehme <slow@samba.org>
Sat, 29 Mar 2025 18:05:29 +0000 (18:05 +0000)
This causes compiler conniptions because the check is tautologically
false with 64 bit size_t, while a 32 bit ssize_t that wraps to a
negative number is rejected by PyList_New(). Besides which, out of
bounds access is blocked by PyList_SetItem(), and talloc won't create
arrays that large.

The trouble is picky compilers can say things like:

../../source3/libsmb/pylibsmb.c: In function ‘py_smb_posix_whoami’:
../../source3/libsmb/pylibsmb.c:2226:22: warning: comparison is always
false due to limited range of data type [-Wtype-limits]
 2226 |         if (num_gids > PY_SSIZE_T_MAX) {

 which draws endless but useless developer attention.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/pylibsmb.c

index bfbddbd5e7b8a4f6e6b24e0e069c5f6ffcaa17b1..c6c8f0083504ad4df19e9767dd2b3e1730e019ce 100644 (file)
@@ -2499,14 +2499,6 @@ static PyObject *py_smb_posix_whoami(struct py_cli_state *self,
                PyErr_SetNTSTATUS(status);
                goto fail;
        }
-       if (num_gids > PY_SSIZE_T_MAX) {
-               PyErr_SetString(PyExc_OverflowError, "posix_whoami: Too many GIDs");
-               goto fail;
-       }
-       if (num_sids > PY_SSIZE_T_MAX) {
-               PyErr_SetString(PyExc_OverflowError, "posix_whoami: Too many SIDs");
-               goto fail;
-       }
 
        py_gids = PyList_New(num_gids);
        if (!py_gids) {