#28 Check negative return of PyList_Size
Closed 2 years ago Opened 2 years ago by jhrozek.

In case of an error, PyList_Size can return a negative value. We should check that case, at the very least to avoid compiler warnings like:

Error: COMPILER_WARNING: [#def41] [warning: defect not occurring in libuser-0.60-9.el7]
libuser-0.62/python/misc.c: scope_hint: In function 'libuser_admin_prompt'
libuser-0.62/python/misc.c:160:12: warning: argument 1 range [9223372036854775808, 18446744073709551615] exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
#  prompts = g_malloc0_n(count, sizeof(struct lu_prompt));
#            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/glist.h:32: included_from: Included from here.
/usr/include/glib-2.0/glib/ghash.h:33: included_from: Included from here.
/usr/include/glib-2.0/glib.h:50: included_from: Included from here.
libuser-0.62/python/misc.c:25: included_from: Included from here.
/usr/include/glib-2.0/glib/gmem.h:96:10: note: in a call to allocation function 'g_malloc0_n' declared here

Note that we might also need to check if the size is within PTRDIFF_MAX, but the error checking is a good idea nonetheless.


Metadata Update from @jhrozek:
- Issue assigned to jhrozek

2 years ago

Metadata Update from @jhrozek:
- Issue status updated to: Closed (was: Open)

2 years ago

Login to comment on this ticket.

Metadata