Module: kamailio
Branch: master
Commit: a6efe6d7e1a205a9d0c2d5c6c165fe337c4de814
URL:
https://github.com/kamailio/kamailio/commit/a6efe6d7e1a205a9d0c2d5c6c165fe3…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-10-25T22:56:47+02:00
app_python: safety checks for self var pointer
---
Modified: src/modules/app_python/python_msgobj.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a6efe6d7e1a205a9d0c2d5c6c165fe3…
Patch:
https://github.com/kamailio/kamailio/commit/a6efe6d7e1a205a9d0c2d5c6c165fe3…
---
diff --git a/src/modules/app_python/python_msgobj.c
b/src/modules/app_python/python_msgobj.c
index 33ddd8db3a..a9dd51d52f 100644
--- a/src/modules/app_python/python_msgobj.c
+++ b/src/modules/app_python/python_msgobj.c
@@ -70,6 +70,12 @@ static PyObject *msg_rewrite_ruri(msgobject *self, PyObject *args)
{
str nuri;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -99,6 +105,12 @@ static PyObject *msg_set_dst_uri(msgobject *self, PyObject *args)
{
str ruri;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -133,6 +145,12 @@ static PyObject *msg_getHeader(msgobject *self, PyObject *args)
struct hdr_field *hf;
str hname, *hbody;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -172,6 +190,12 @@ PyObject *msg_call_function(msgobject *self, PyObject *args)
struct run_act_ctx ra_ctx;
unsigned mod_ver;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -281,6 +305,12 @@ static PyObject *msg_getType(msgobject *self, PyObject *unused)
{
const char *rval;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -309,6 +339,12 @@ static PyObject *msg_getMethod(msgobject *self, PyObject *unused)
{
str *rval;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -328,6 +364,12 @@ static PyObject *msg_getStatus(msgobject *self, PyObject *unused)
{
str *rval;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -348,6 +390,12 @@ static PyObject *msg_getRURI(msgobject *self, PyObject *unused)
{
str *rval;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -368,6 +416,12 @@ static PyObject *msg_get_src_address(msgobject *self, PyObject
*unused)
{
PyObject *src_ip, *src_port, *pyRval;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);
@@ -402,6 +456,12 @@ static PyObject *msg_get_dst_address(msgobject *self, PyObject
*unused)
{
PyObject *dst_ip, *dst_port, *pyRval;
+ if (self == NULL) {
+ PyErr_SetString(PyExc_RuntimeError, "self is NULL");
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
if (self->msg == NULL) {
PyErr_SetString(PyExc_RuntimeError, "self->msg is NULL");
Py_INCREF(Py_None);