Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app_python3: fix kemi function call argument type checks #1568

Merged
merged 1 commit into from Jun 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
59 changes: 40 additions & 19 deletions src/modules/app_python3/apy_kemi.c 100644 → 100755
Expand Up @@ -216,14 +216,17 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
}
LM_DBG("param[%d] for: %.*s is int: %d\n", i,
fname.len, fname.s, vps[0].n);
} else {
} else if(ket->ptypes[0]==SR_KEMIP_STR) {
if(!PyArg_ParseTuple(args, "s:kemi-param-s", &vps[0].s.s)) {
LM_ERR("unable to retrieve str param %d\n", 0);
return sr_kemi_apy_return_false();
}
vps[0].s.len = strlen(vps[0].s.s);
LM_DBG("param[%d] for: %.*s is str: %.*s\n", i,
fname.len, fname.s, vps[0].s.len, vps[0].s.s);
} else {
LM_ERR("not implemented yet\n");
return sr_kemi_apy_return_false();
}
} else if(ket->ptypes[2]==SR_KEMIP_NONE) {
i = 2;
Expand All @@ -250,7 +253,7 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
vps[0].s.len = strlen(vps[0].s.s);
LM_DBG("params[%d] for: %.*s are str-int: [%.*s] [%d]\n", i,
fname.len, fname.s, vps[0].s.len, vps[0].s.s, vps[1].n);
} else {
} else if(ket->ptypes[0]==SR_KEMIP_STR && ket->ptypes[1]==SR_KEMIP_STR) {
if(!PyArg_ParseTuple(args, "ss:kemi-param-ss", &vps[0].s.s, &vps[1].s.s)) {
LM_ERR("unable to retrieve str-str param %d\n", i);
return sr_kemi_apy_return_false();
Expand All @@ -260,6 +263,9 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
LM_DBG("params[%d] for: %.*s are str: [%.*s] [%.*s]\n", i,
fname.len, fname.s, vps[0].s.len, vps[0].s.s,
vps[1].s.len, vps[1].s.s);
} else {
LM_ERR("not implemented yet\n");
return sr_kemi_apy_return_false();
}

} else if(ket->ptypes[3]==SR_KEMIP_NONE) {
Expand Down Expand Up @@ -338,9 +344,9 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
} else if(ket->ptypes[4]==SR_KEMIP_NONE) {
i = 4;
if(ket->ptypes[0]==SR_KEMIP_STR
|| ket->ptypes[1]==SR_KEMIP_STR
|| ket->ptypes[2]==SR_KEMIP_STR
|| ket->ptypes[3]==SR_KEMIP_STR) {
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_STR) {
if(!PyArg_ParseTuple(args, "ssss:kemi-param-ssss",
&vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s)) {
LM_ERR("unable to retrieve str-str-str-str params %d\n", i);
Expand All @@ -356,9 +362,9 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
vps[1].s.len, vps[1].s.s, vps[2].s.len, vps[2].s.s,
vps[3].s.len, vps[3].s.s);
} else if(ket->ptypes[0]==SR_KEMIP_STR
|| ket->ptypes[1]==SR_KEMIP_STR
|| ket->ptypes[2]==SR_KEMIP_INT
|| ket->ptypes[3]==SR_KEMIP_INT) {
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_INT
&& ket->ptypes[3]==SR_KEMIP_INT) {
if(!PyArg_ParseTuple(args, "ssii:kemi-param-ssnn",
&vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].n)) {
LM_ERR("unable to retrieve str-str-int-int params %d\n", i);
Expand All @@ -370,17 +376,32 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
" [%d] [%d]\n", i,
fname.len, fname.s, vps[0].s.len, vps[0].s.s,
vps[1].s.len, vps[1].s.s, vps[2].n, vps[3].n);
} else if(ket->ptypes[0]==SR_KEMIP_INT
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_STR) {
if(!PyArg_ParseTuple(args, "isss:kemi-param-nsss",
&vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s)) {
LM_ERR("unable to retrieve int-str-str-str params %d\n", i);
return sr_kemi_apy_return_false();
}
vps[1].s.len = strlen(vps[1].s.s);
vps[2].s.len = strlen(vps[2].s.s);
vps[3].s.len = strlen(vps[3].s.s);
LM_DBG("params[%d] for: %.*s are str: [%d] [%.*s] [%.*s] [%.*s]\n", i,
fname.len, fname.s, vps[0].n, vps[1].s.len, vps[1].s.s,
vps[2].s.len, vps[2].s.s, vps[3].s.len, vps[3].s.s);
} else {
LM_ERR("not implemented yet\n");
return sr_kemi_apy_return_false();
}
} else if(ket->ptypes[5]==SR_KEMIP_NONE) {
i = 5;
if(ket->ptypes[0]==SR_KEMIP_STR
|| ket->ptypes[1]==SR_KEMIP_STR
|| ket->ptypes[2]==SR_KEMIP_STR
|| ket->ptypes[3]==SR_KEMIP_STR
|| ket->ptypes[4]==SR_KEMIP_STR) {
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_STR
&& ket->ptypes[4]==SR_KEMIP_STR) {
if(!PyArg_ParseTuple(args, "sssss:kemi-param-sssss",
&vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s,
&vps[4].s.s)) {
Expand All @@ -404,11 +425,11 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
} else {
i = 6;
if(ket->ptypes[0]==SR_KEMIP_STR
|| ket->ptypes[1]==SR_KEMIP_STR
|| ket->ptypes[2]==SR_KEMIP_STR
|| ket->ptypes[3]==SR_KEMIP_STR
|| ket->ptypes[4]==SR_KEMIP_STR
|| ket->ptypes[5]==SR_KEMIP_STR) {
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_STR
&& ket->ptypes[4]==SR_KEMIP_STR
&& ket->ptypes[5]==SR_KEMIP_STR) {
if(!PyArg_ParseTuple(args, "ssssss:kemi-param-ssssss",
&vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s,
&vps[4].s.s, &vps[5].s.s)) {
Expand Down Expand Up @@ -574,7 +595,7 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_INT) {
/* ssnn */
/* sssn */
ret = ((sr_kemi_fmsssn_f)(ket->func))(lmsg,
&vps[0].s, &vps[1].s, &vps[2].s, vps[3].n);
return sr_kemi_apy_return_int(ket, ret);
Expand All @@ -590,7 +611,7 @@ PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
&& ket->ptypes[1]==SR_KEMIP_STR
&& ket->ptypes[2]==SR_KEMIP_STR
&& ket->ptypes[3]==SR_KEMIP_STR) {
/* ssnn */
/* nsss */
ret = ((sr_kemi_fmnsss_f)(ket->func))(lmsg,
vps[0].n, &vps[1].s, &vps[2].s, &vps[3].s);
return sr_kemi_apy_return_int(ket, ret);
Expand Down