diff options
author | xuhy <huayong.xu@samsung.com> | 2023-11-16 17:39:20 +0800 |
---|---|---|
committer | xuhy <huayong.xu@samsung.com> | 2023-11-16 17:39:20 +0800 |
commit | 76ea0b5d4a1b8180f2552c2729d84388a77beecb (patch) | |
tree | 9a2b028c24c205b075d9386acd7a62a2eb2271a7 /python/rpmts-py.c | |
parent | c30d127e8780dc678168ee121b9f2eeb1a8aaafa (diff) | |
download | librpm-tizen-76ea0b5d4a1b8180f2552c2729d84388a77beecb.tar.gz librpm-tizen-76ea0b5d4a1b8180f2552c2729d84388a77beecb.tar.bz2 librpm-tizen-76ea0b5d4a1b8180f2552c2729d84388a77beecb.zip |
The following issues are fixed:
1. Prevent execution of arbitrary scripts
2. Enable dash(-) in spec file.
3. Ignore bad expressions in %if conditionals.
4. Ignore unknown tags.
5. Ignore error macro.
Change-Id: Id5b7b47c1a78de364ef0d513023fbe9ccc773a87
Signed-off-by: xuhy <huayong.xu@samsung.com>
Diffstat (limited to 'python/rpmts-py.c')
-rw-r--r-- | python/rpmts-py.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/python/rpmts-py.c b/python/rpmts-py.c index d56a09c22..d6ae23750 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -230,16 +230,17 @@ rpmts_SolveCallback(rpmts ts, rpmds ds, const void * data) PyEval_RestoreThread(cbInfo->_save); - args = Py_BuildValue("(Oissi)", cbInfo->tso, - rpmdsTagN(ds), rpmdsN(ds), rpmdsEVR(ds), rpmdsFlags(ds)); - result = PyEval_CallObject(cbInfo->cb, args); + args = Py_BuildValue("(OiNNi)", cbInfo->tso, + rpmdsTagN(ds), utf8FromString(rpmdsN(ds)), + utf8FromString(rpmdsEVR(ds)), rpmdsFlags(ds)); + result = PyObject_Call(cbInfo->cb, args, NULL); Py_DECREF(args); if (!result) { die(cbInfo->cb); } else { - if (PyInt_Check(result)) - res = PyInt_AsLong(result); + if (PyLong_Check(result)) + res = PyLong_AsLong(result); Py_DECREF(result); } @@ -409,7 +410,7 @@ rpmts_HdrCheck(rpmtsObject * s, PyObject *obj) rpmrc = headerCheck(s->ts, uh, uc, &msg); Py_END_ALLOW_THREADS; - return Py_BuildValue("(is)", rpmrc, msg); + return Py_BuildValue("(iN)", rpmrc, utf8FromString(msg)); } static PyObject * @@ -459,7 +460,7 @@ static PyObject *rpmts_setKeyring(rpmtsObject *s, PyObject *arg) if (arg == Py_None || rpmKeyringFromPyObject(arg, &keyring)) { return PyBool_FromLong(rpmtsSetKeyring(s->ts, keyring) == 0); } else { - PyErr_SetString(PyExc_TypeError, "rpm.keyring or None expected"); + PyErr_SetString(PyExc_TypeError, PYTHON_MODULENAME".keyring or None expected"); return NULL; } } @@ -498,7 +499,7 @@ rpmtsCallback(const void * hd, const rpmCallbackType what, /* Synthesize a python object for callback (if necessary). */ if (pkgObj == NULL) { if (h) { - pkgObj = Py_BuildValue("s", headerGetString(h, RPMTAG_NAME)); + pkgObj = utf8FromString(headerGetString(h, RPMTAG_NAME)); } else { pkgObj = Py_None; Py_INCREF(pkgObj); @@ -509,7 +510,7 @@ rpmtsCallback(const void * hd, const rpmCallbackType what, PyEval_RestoreThread(cbInfo->_save); args = Py_BuildValue("(iLLOO)", what, amount, total, pkgObj, cbInfo->data); - result = PyEval_CallObject(cbInfo->cb, args); + result = PyObject_Call(cbInfo->cb, args, NULL); Py_DECREF(args); Py_DECREF(pkgObj); @@ -624,8 +625,8 @@ rpmts_Match(rpmtsObject * s, PyObject * args, PyObject * kwds) return NULL; if (Key) { - if (PyInt_Check(Key)) { - lkey = PyInt_AsLong(Key); + if (PyLong_Check(Key)) { + lkey = PyLong_AsLong(Key); key = (char *)&lkey; len = sizeof(lkey); } else if (PyLong_Check(Key)) { @@ -845,7 +846,7 @@ static PyObject *rpmts_get_tid(rpmtsObject *s, void *closure) static PyObject *rpmts_get_rootDir(rpmtsObject *s, void *closure) { - return Py_BuildValue("s", rpmtsRootDir(s->ts)); + return utf8FromString(rpmtsRootDir(s->ts)); } static int rpmts_set_scriptFd(rpmtsObject *s, PyObject *value, void *closure) @@ -968,7 +969,7 @@ static PyGetSetDef rpmts_getseters[] = { PyTypeObject rpmts_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "rpm.ts", /* tp_name */ + PYTHON_MODULENAME".ts", /* tp_name */ sizeof(rpmtsObject), /* tp_size */ 0, /* tp_itemsize */ (destructor) rpmts_dealloc, /* tp_dealloc */ |