Commits

Christian Heimes committed 5786f3c

also check error in getattro function

  • Participants
  • Parent commits 8d56e34

Comments (0)

Files changed (5)

File Modules26/_elementtree.c

 #ifdef XML_BOMB_PROTECTION
     else if (strcmp(name, "ignore_dtd") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD, &value);
+        if (!EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyBool_FromLong(value);
     }
     else if (strcmp(name, "max_entity_indirections") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
-                          &value);
+        if (!EXPAT(GetFeature)(self->parser,
+                               XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyLong_FromLong(value);
     }
     else if (strcmp(name, "max_entity_expansions") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_EXPANSIONS,
-                          &value);
+        if (!EXPAT(GetFeature)(self->parser,
+                               XML_FEATURE_MAX_ENTITY_EXPANSIONS,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyLong_FromLong(value);
     }
 #endif

File Modules27/_elementtree.c

 #ifdef XML_BOMB_PROTECTION
     else if (strcmp(name, "ignore_dtd") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD, &value);
+        if (!EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyBool_FromLong(value);
     }
     else if (strcmp(name, "max_entity_indirections") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
-                          &value);
+        if (!EXPAT(GetFeature)(self->parser,
+                               XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyLong_FromLong(value);
     }
     else if (strcmp(name, "max_entity_expansions") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_EXPANSIONS,
-                          &value);
+        if (!EXPAT(GetFeature)(self->parser,
+                               XML_FEATURE_MAX_ENTITY_EXPANSIONS,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyLong_FromLong(value);
     }
 #endif

File Modules31/_elementtree.c

     }
     else if (strcmp(name, "ignore_dtd") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD, &value);
+        if (!EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyBool_FromLong(value);
     }
     else if (strcmp(name, "max_entity_indirections") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
-                          &value);
+        if (!EXPAT(GetFeature)(self->parser,
+                               XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyLong_FromLong(value);
     }
     else if (strcmp(name, "max_entity_expansions") == 0) {
         long value = -1;
-        EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_EXPANSIONS,
-                          &value);
+        if (!EXPAT(GetFeature)(self->parser,
+                               XML_FEATURE_MAX_ENTITY_EXPANSIONS,
+                               &value)) {
+            return PyErr_SetFromErrno(PyExc_ValueError);
+        }
         return PyLong_FromLong(value);
 #endif
     } else {

File Modules32/_elementtree.c

 #ifdef XML_BOMB_PROTECTION
         else if (PyUnicode_CompareWithASCIIString(nameobj, "ignore_dtd") == 0) {
             long value = -1;
-            EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD, &value);
+            if (!EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD,
+                                   &value)) {
+                return PyErr_SetFromErrno(PyExc_ValueError);
+            }
+
             return PyBool_FromLong(value);
         }
         else if (PyUnicode_CompareWithASCIIString(nameobj, "max_entity_indirections") == 0) {
             long value = -1;
-            EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
-                              &value);
+            if (!EXPAT(GetFeature)(self->parser,
+                                   XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
+                                   &value)) {
+                return PyErr_SetFromErrno(PyExc_ValueError);
+            }
             return PyLong_FromLong(value);
         }
         else if (PyUnicode_CompareWithASCIIString(nameobj, "max_entity_expansions") == 0) {
             long value = -1;
-            EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_EXPANSIONS,
-                              &value);
+            if (!EXPAT(GetFeature)(self->parser,
+                                   XML_FEATURE_MAX_ENTITY_EXPANSIONS,
+                                   &value)) {
+                return PyErr_SetFromErrno(PyExc_ValueError);
+            }
             return PyLong_FromLong(value);
         }
 #endif

File Modules33/_elementtree.c

 #ifdef XML_BOMB_PROTECTION
         else if (PyUnicode_CompareWithASCIIString(nameobj, "ignore_dtd") == 0) {
             long value = -1;
-            EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD, &value);
+            if (!EXPAT(GetFeature)(self->parser, XML_FEATURE_RESET_DTD,
+                                   &value)) {
+                return PyErr_SetFromErrno(PyExc_ValueError);
+            }
+
             return PyBool_FromLong(value);
         }
         else if (PyUnicode_CompareWithASCIIString(nameobj, "max_entity_indirections") == 0) {
             long value = -1;
-            EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
-                              &value);
+            if (!EXPAT(GetFeature)(self->parser,
+                                   XML_FEATURE_MAX_ENTITY_INDIRECTIONS,
+                                   &value)) {
+                return PyErr_SetFromErrno(PyExc_ValueError);
+            }
             return PyLong_FromLong(value);
         }
         else if (PyUnicode_CompareWithASCIIString(nameobj, "max_entity_expansions") == 0) {
             long value = -1;
-            EXPAT(GetFeature)(self->parser, XML_FEATURE_MAX_ENTITY_EXPANSIONS,
-                              &value);
+            if (!EXPAT(GetFeature)(self->parser,
+                                   XML_FEATURE_MAX_ENTITY_EXPANSIONS,
+                                   &value)) {
+                return PyErr_SetFromErrno(PyExc_ValueError);
+            }
             return PyLong_FromLong(value);
         }
 #endif