centos 7
integer weakness #18


Weakness Breakdown


An integer overflow occurs when the answer to an arithmetic operation exceeds the maximum size of the integer type used to store it. The resulting value will appear to have wrapped around the maximum value and started again at the minimum value. This would look like a clock that represents 13:00 by pointing at 1:00. An attacker can use an integer overflow during a buffer length calculation, which results in the allocated buffer being too small to hold the data copied into it, thus causing a buffer overflow.

Warning code(s):

Unless checked, the resulting number can exceed the expected range.

File Name:



The highlighted line of code below is the trigger point of this particular Centos 7 integer weakness.

                                 if( (xpo->nodesetval != NULL) && (xpo->nodesetval->nodeNr > 0) ) {
                                        value = PyList_New(0);

                                        // If we're working on a fixed list, create one which contains
                                        // only Py_None objects.  Otherwise the list will be filled with
                                        // <nil> elements.
                                        if( map_p->fixed_list_size > 0 ) {
                                                for( i = 0; i < map_p->fixed_list_size; i++ ) {
                                                        PyList_Append(value, Py_None);

                                        for( i = 0; i < xpo->nodesetval->nodeNr; i++ ) {
                                                char *valstr = NULL;
                                                valstr = (char *) malloc(4098);
                                                dmixml_GetXPathContent(logp, valstr, 4097, xpo, i);

                                                // If we have a fixed list and we have a index value for the list
                                                if( (map_p->fixed_list_size > 0) && (map_p->list_index != NULL) ) {
                                                        char *idx = NULL;

                                                        idx = dmixml_GetAttrValue(xpo->nodesetval->nodeTab[i],
                                                        if( idx != NULL ) {
                                                                PyList_SetItem(value, atoi(idx)-1,
											     map_p, valstr)
                                                } else {
                                                        // No list index - append the value
                                } else {
                                        value = Py_None;
                                PyADD_DICT_VALUE(retdata, key, value);
                        } else {
                                PyReturnError(PyExc_ValueError, "Could not get key value: "
                                              "%s [%i] (Defining key: %s)",
                                              map_p->rootpath, elmtid, map_p->key);

        case ptzDICT:
                // Traverse children nodes 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.