New python PIDL checks cause 2221 new Coverity warnings
Volker Lendecke
Volker.Lendecke at SerNet.DE
Tue Aug 25 05:57:53 UTC 2015
Hi, Andrew!
The new PIDL checks for generated python code cause tons of new warnings
in Coverity.
One random example pasted after this message, please take a look at the
lines with CID. The web interface is much more usable, I'm pasting this
example here for easy access.
Is there anything we can do about this? Filtering out all generated
python code would be one possibility, but I would rather not do it.
Thanks,
Volker
12150static int py_drsuapi_DsGetNT4ChangeLogInfo1_set_builtin_serial_number(PyObject *py_obj, PyObject *value, void *closure)
12151{
12152 struct drsuapi_DsGetNT4ChangeLogInfo1 *object = (struct drsuapi_DsGetNT4ChangeLogInfo1 *)pytalloc_get_ptr(py_obj);
12153 {
CID 1318037 (#1 of 1): Bad bit shift operation (BAD_SHIFT)1. large_shift: In expression 1ULL << 64UL, left shifting by more than 63 bits has undefined behavior. The shift amount is 64.
12154 const unsigned long long uint_max = (sizeof(object->builtin_serial_number) == 8) ? UINT64_MAX : (unsigned long long)((1ULL << (sizeof(object->builtin_serial_number) * 8)) - 1);
12155 if (PyLong_Check(value)) {
12156 unsigned long long test_var;
12157 test_var = PyLong_AsUnsignedLongLong(value);
12158 if (PyErr_Occurred() != NULL) {
12159 return -1;
12160 }
CID 1318233: Operands don't affect result (CONSTANT_EXPRESSION_RESULT) [select issue]
12161 if (test_var > uint_max) {
12162 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %llu",\
12163 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
12164 return -1;
12165 }
12166 object->builtin_serial_number = test_var;
12167 } else if (PyInt_Check(value)) {
12168 long test_var;
12169 test_var = PyInt_AsLong(value);
CID 1318233: Operands don't affect result (CONSTANT_EXPRESSION_RESULT) [select issue]
12170 if (test_var < 0 || test_var > uint_max) {
12171 PyErr_Format(PyExc_OverflowError, "Expected type %s or %s within range 0 - %llu, got %ld",\
12172 PyInt_Type.tp_name, PyLong_Type.tp_name, uint_max, test_var);
12173 return -1;
12174 }
12175 object->builtin_serial_number = test_var;
12176 } else {
12177 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
12178 PyInt_Type.tp_name, PyLong_Type.tp_name);
12179 return -1;
12180 }
12181 }
12182 return 0;
12183}
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
More information about the samba-technical
mailing list