Browse Source

[1245] add NULL checks in PyXXX_ToXXX() functions

Jelte Jansen 13 years ago
parent
commit
3eb0dedb8a

+ 4 - 0
src/lib/dns/python/edns_python.cc

@@ -380,6 +380,10 @@ PyEDNS_Check(PyObject* obj) {
 
 const EDNS&
 PyEDNS_ToEDNS(const PyObject* edns_obj) {
+    if (edns_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in EDNS PyObject conversion");
+    }
     const s_EDNS* edns = static_cast<const s_EDNS*>(edns_obj);
     return (*edns->cppobj);
 }

+ 4 - 0
src/lib/dns/python/messagerenderer_python.cc

@@ -253,6 +253,10 @@ PyMessageRenderer_Check(PyObject* obj) {
 
 MessageRenderer&
 PyMessageRenderer_ToMessageRenderer(PyObject* messagerenderer_obj) {
+    if (messagerenderer_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in MessageRenderer PyObject conversion");
+    }
     s_MessageRenderer* messagerenderer = static_cast<s_MessageRenderer*>(messagerenderer_obj);
     return (*messagerenderer->cppobj);
 }

+ 4 - 0
src/lib/dns/python/name_python.cc

@@ -654,6 +654,10 @@ PyName_Check(PyObject* obj) {
 
 const Name&
 PyName_ToName(const PyObject* name_obj) {
+    if (name_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in Name PyObject conversion");
+    }
     const s_Name* name = static_cast<const s_Name*>(name_obj);
     return (*name->cppobj);
 }

+ 4 - 0
src/lib/dns/python/opcode_python.cc

@@ -358,6 +358,10 @@ PyOpcode_Check(PyObject* obj) {
 
 const Opcode&
 PyOpcode_ToOpcode(const PyObject* opcode_obj) {
+    if (opcode_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in Opcode PyObject conversion");
+    }
     const s_Opcode* opcode = static_cast<const s_Opcode*>(opcode_obj);
     return (*opcode->cppobj);
 }

+ 4 - 0
src/lib/dns/python/question_python.cc

@@ -308,6 +308,10 @@ PyQuestion_Check(PyObject* obj) {
 
 const Question&
 PyQuestion_ToQuestion(const PyObject* question_obj) {
+    if (question_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in Question PyObject conversion");
+    }
     const s_Question* question = static_cast<const s_Question*>(question_obj);
     return (*question->cppobj);
 }

+ 4 - 0
src/lib/dns/python/rcode_python.cc

@@ -398,6 +398,10 @@ PyRcode_Check(PyObject* obj) {
 
 const Rcode&
 PyRcode_ToRcode(const PyObject* rcode_obj) {
+    if (rcode_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in Rcode PyObject conversion");
+    }
     const s_Rcode* rcode = static_cast<const s_Rcode*>(rcode_obj);
     return (*rcode->cppobj);
 }

+ 4 - 0
src/lib/dns/python/rdata_python.cc

@@ -285,6 +285,10 @@ PyRdata_Check(PyObject* obj) {
 
 const Rdata&
 PyRdata_ToRdata(const PyObject* rdata_obj) {
+    if (rdata_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in Rdata PyObject conversion");
+    }
     const s_Rdata* rdata = static_cast<const s_Rdata*>(rdata_obj);
     return (*rdata->cppobj);
 }

+ 4 - 0
src/lib/dns/python/rrclass_python.cc

@@ -353,6 +353,10 @@ PyRRClass_Check(PyObject* obj) {
 
 const RRClass&
 PyRRClass_ToRRClass(const PyObject* rrclass_obj) {
+    if (rrclass_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in RRClass PyObject conversion");
+    }
     const s_RRClass* rrclass = static_cast<const s_RRClass*>(rrclass_obj);
     return (*rrclass->cppobj);
 }

+ 4 - 0
src/lib/dns/python/rrset_python.cc

@@ -448,6 +448,10 @@ PyRRset_ToRRset(PyObject* rrset_obj) {
 
 RRsetPtr
 PyRRset_ToRRsetPtr(PyObject* rrset_obj) {
+    if (rrset_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in RRset PyObject conversion");
+    }
     s_RRset* rrset = static_cast<s_RRset*>(rrset_obj);
     return (rrset->cppobj);
 }

+ 4 - 0
src/lib/dns/python/rrttl_python.cc

@@ -308,6 +308,10 @@ PyRRTTL_Check(PyObject* obj) {
 
 const RRTTL&
 PyRRTTL_ToRRTTL(const PyObject* rrttl_obj) {
+    if (rrttl_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in RRTTL PyObject conversion");
+    }
     const s_RRTTL* rrttl = static_cast<const s_RRTTL*>(rrttl_obj);
     return (*rrttl->cppobj);
 }

+ 4 - 0
src/lib/dns/python/rrtype_python.cc

@@ -450,6 +450,10 @@ PyRRType_Check(PyObject* obj) {
 
 const RRType&
 PyRRType_ToRRType(const PyObject* rrtype_obj) {
+    if (rrtype_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in RRType PyObject conversion");
+    }
     const s_RRType* rrtype = static_cast<const s_RRType*>(rrtype_obj);
     return (*rrtype->cppobj);
 }

+ 4 - 0
src/lib/dns/python/tsig_python.cc

@@ -312,6 +312,10 @@ PyTSIGContext_Check(PyObject* obj) {
 
 TSIGContext&
 PyTSIGContext_ToTSIGContext(PyObject* tsigcontext_obj) {
+    if (tsigcontext_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in TSIGContext PyObject conversion");
+    }
     s_TSIGContext* tsigcontext = static_cast<s_TSIGContext*>(tsigcontext_obj);
     return (*tsigcontext->cppobj);
 }

+ 4 - 0
src/lib/dns/python/tsig_rdata_python.cc

@@ -354,6 +354,10 @@ PyTSIG_Check(PyObject* obj) {
 
 const any::TSIG&
 PyTSIG_ToTSIG(const PyObject* tsig_obj) {
+    if (tsig_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in TSIG PyObject conversion");
+    }
     const s_TSIG* tsig = static_cast<const s_TSIG*>(tsig_obj);
     return (*tsig->cppobj);
 }

+ 4 - 0
src/lib/dns/python/tsigkey_python.cc

@@ -454,6 +454,10 @@ PyTSIGKeyRing_Check(PyObject* obj) {
 
 const TSIGKeyRing&
 PyTSIGKeyRing_ToTSIGKeyRing(const PyObject* tsigkeyring_obj) {
+    if (tsigkeyring_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in TSIGKeyRing PyObject conversion");
+    }
     const s_TSIGKeyRing* tsigkeyring =
         static_cast<const s_TSIGKeyRing*>(tsigkeyring_obj);
     return (*tsigkeyring->cppobj);

+ 4 - 0
src/lib/dns/python/tsigrecord_python.cc

@@ -279,6 +279,10 @@ PyTSIGRecord_Check(PyObject* obj) {
 
 const TSIGRecord&
 PyTSIGRecord_ToTSIGRecord(PyObject* tsigrecord_obj) {
+    if (tsigrecord_obj == NULL) {
+        isc_throw(PyCPPWrapperException,
+                  "obj argument NULL in TSIGRecord PyObject conversion");
+    }
     s_TSIGRecord* tsigrecord = static_cast<s_TSIGRecord*>(tsigrecord_obj);
     return (*tsigrecord->cppobj);
 }