summaryrefslogtreecommitdiff
path: root/python/rpmds-py.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-09-22 19:19:02 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-09-22 19:19:02 +0300
commitda74188fa654246ec74e0375440f326e5dc714f2 (patch)
tree81ab358d268b42147278025a23e8a1c701a98c3d /python/rpmds-py.c
parent00d683ce88748080ce78d1e2d802a401b2d30261 (diff)
downloadrpm-da74188fa654246ec74e0375440f326e5dc714f2.tar.gz
rpm-da74188fa654246ec74e0375440f326e5dc714f2.tar.bz2
rpm-da74188fa654246ec74e0375440f326e5dc714f2.zip
Sanitize python object -> tag number exception handling
- raise exception in tagNumFromPyObject(), not in 12 different callers - check against RPMTAG_NOT_FOUND consistently instead of -1 and whatnot - unknown tags are value, not key or type errors
Diffstat (limited to 'python/rpmds-py.c')
-rw-r--r--python/rpmds-py.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/python/rpmds-py.c b/python/rpmds-py.c
index 223c27d9d..125b3d252 100644
--- a/python/rpmds-py.c
+++ b/python/rpmds-py.c
@@ -507,10 +507,7 @@ static PyObject * rpmds_new(PyTypeObject * subtype, PyObject *args, PyObject *kw
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
s->ds = rpmdsNew(hdrGetHeader(ho), tagN, 0);
@@ -603,10 +600,7 @@ rpmds_Single(PyObject * s, PyObject * args, PyObject * kwds)
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
if (N != NULL) N = xstrdup(N);
if (EVR != NULL) EVR = xstrdup(EVR);
@@ -628,10 +622,7 @@ hdr_dsFromHeader(PyObject * s, PyObject * args, PyObject * kwds)
if (to != NULL) {
tagN = tagNumFromPyObject(to);
- if (tagN == -1) {
- PyErr_SetString(PyExc_KeyError, "unknown header tag");
- return NULL;
- }
+ if (tagN == RPMTAG_NOT_FOUND) return NULL;
}
return rpmds_Wrap( rpmdsNew(hdrGetHeader(ho), tagN, 0) );
}