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>
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) {