summaryrefslogtreecommitdiff
path: root/python/rpmfd-py.c
AgeCommit message (Collapse)AuthorFilesLines
2012-01-02fix use-after-free within rpmfdFromPyObject's error-handlingDavid Malcolm1-1/+1
These lines within python/rpmfd-py.c: rpmfdFromPyObject are the wrong way around: Py_DECREF(fdo); PyErr_SetString(PyExc_IOError, Fstrerror(fdo->fd)); If fdo was allocated by the call above to PyObject_CallFunctionObjArgs, it may have an ob_refcnt == 1, and thus the Py_DECREF() frees it, so fdo->fd is reading from deallocated memory. Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
2011-12-22mark strings extracted from PyArg_Parse* as "const"David Malcolm1-2/+2
- Various places within the bindings use PyArg_ParseTuple[AndKeywords] to extract (char*) string arguments. These are pointers to the internal representation of a PyStringObject, and shouldn't be modified, hence it's safest to explicitly mark these values as (const char*), rather than just (char*). Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
2011-12-21fix memory leaks in invocations of PyObject_CallDavid Malcolm1-2/+2
- Various functions in the Python bindings have expressions of the form: PyObject_Call(callable, Py_BuildValue(fmtstring, ...), NULL); This leaks memory for the case when Py_BuildValue succeeds (it returns a new reference, which is never freed; PyObject_Call doesn't steal the reference): the argument tuple and all of its components will not be freed (until the process exits). Signed-off-by: Ales Kozumplik <akozumpl@redhat.com>
2011-07-07Teach python rpmio bindings about Fdescr()Panu Matilainen1-0/+7
- Similarly to python file object having o.name, export Fdescr() as fd.name. Python uses <foo> for non-paths but [foo] seems like a safer choice wrt accidental redirections. - Also add a basic testcase for fd.name
2011-07-01Fix/sanitize rpm.fd python object creationPanu Matilainen1-22/+14
- FD's are not really immutable, move the initialization work into tp_init and use PyType_GenericNew for tp_new since we're not doing anything special there. - Remove half a dozen different unnecessary exit points
2011-07-01Fix the totally broken rpm.fd() read methodPanu Matilainen1-20/+25
2011-03-04Throw an exception from Fseek() errors in python rpmfd.seek()Panu Matilainen1-1/+1
2010-11-23Oops, missing include in previous commitPanu Matilainen1-0/+1
2010-11-23Permit unicode paths in rpm.fd() (RhBug:654145)Panu Matilainen1-5/+26
- Python 3 has fs-specific converter function, for Python 2 just assume utf-8 and hope the best.
2009-10-28Remove unnecessary (cmpfunc) casts from our type objectsPanu Matilainen1-1/+1
- cmpfunc is no more in Python 3 and casting NULL to anything makes little sense anyhow
2009-10-28Use PyObject_AsFileDescriptor() instead of object type comparisonPanu Matilainen1-5/+3
- this permits any file-like object implementing .fileno() method (including rpm.fd) to be dup'ed, not just PyFile subtypes - this also avoids yet another incompatibility with Python 3 which doesn't have PyFile_Check() and PyFile_AsFile() at all
2009-10-21Replace PyString usage with PyBytes everywherePanu Matilainen1-3/+3
- In Python 2.6 PyBytes is just an alias for PyString, Python 3.0 removed PyString entirely - Add compatibility defines for Python < 2.6 - Based on David Malcolm's Python 3.x efforts
2009-10-19Generalize type object initialization to work with both Python 2.* and ↵David Malcolm1-2/+1
Python 3.* The layout of PyVarObject changed between python 2 and python 3, and this leads to the existing code for all of the various PyTypeObject initializers failing to compile with python 3 Change the way we initialize these structs to use PyVarObject_HEAD_INIT directly, rather than merely PyObject_HEAD_INIT, so that it compiles cleanly with both major versions of Python
2009-10-19Generalize access to ob_type so that they work with both Python 2.* and ↵David Malcolm1-1/+1
Python 3.* Python 2's various object structs use macros to implement common fields at the top of each struct. Python 3's objects instead embed a PyObject struct as the first member within the more refined object structs. Use the Py_TYPE() macro when accessing ob_type in order to encapsulate this difference.
2009-10-15Add tell() method to rpm.fd classPanu Matilainen1-0/+12
2009-10-15Accept rpm.fd() types file objects everywhere in python bindingsPanu Matilainen1-20/+31
- turn rpmfdFromPyObject() into a python-level object converter, add a separate C-level getter for the fd pointer itself - take advantage of python refcounting to handle differences between native vs converted rpm.fd in callers so we can simply decref the rpmfdFromPyObject() result without having to worry whether it was converted or not (ie should we close it or not)
2009-10-14Add first rough-cut python bindings for rpmio fdPanu Matilainen1-3/+285
- attempt to mimic python file object where possible, but nowhere near all methods are supported, either just not yet done or due to underlying limitations
2009-09-23Turn rpmFdFromPyObject() into an object converter interfacePanu Matilainen1-3/+6
- permits direct validation and conversion from arg parsing
2009-09-23Add helper to convert python file objects to rpmio FD_t typePanu Matilainen1-0/+22
2009-09-22Lose the utterly broken rpmio FD_t wrappersPanu Matilainen1-305/+0
2009-09-22We dont support ancient python versions...Panu Matilainen1-2/+0
2007-12-16Lone module-private const .. removePanu Matilainen1-1/+1
2007-12-08Switch to <rpm/foo.h> style for public headersPanu Matilainen1-1/+1
- adjust include paths accordingly
2007-12-04Eliminate debug junk from the APIPanu Matilainen1-3/+3
- add some helper macros to accomplish the same, easy to enable / disable as needed
2007-11-23Use #include <x.h> syntax to include public headers.Ralf Corsépius1-1/+1
2007-10-29Use fdGetFILE() instead of rpmio internal fdGetFp() everywherePanu Matilainen1-2/+2
2007-10-23Remove bunch of unnecessary rpmio_internal & related includes from pythonPanu Matilainen1-5/+1
2007-09-11Remove split tags.Ralf Corsépius1-32/+4
2007-07-10Fix bunch of compiler warnings from python bindings (method pointer types)Panu Matilainen1-1/+1
2004-11-17Add kwargs everywhere - courtesy of pjones@redhat.compauln1-7/+14
CVS patchset: 7582 CVS date: 2004/11/17 17:05:39
2004-01-22Build with gcc-2.95.3 and python-2.2, remove incompat CFLAGS and casts.jbj1-1/+1
CVS patchset: 7082 CVS date: 2004/01/22 14:28:08
2004-01-01- python: include Python.h before glibc features.h.jbj1-6/+0
CVS patchset: 7055 CVS date: 2004/01/01 16:34:10
2003-12-30- use -fPIC -DPIC on all platforms, not just mandatory (#112713).jbj1-1/+1
CVS patchset: 7051 CVS date: 2003/12/30 15:12:50
2003-12-01splint fiddles, no warnings.jbj1-0/+7
CVS patchset: 6961 CVS date: 2003/12/01 19:15:38
2003-11-23Merge changes from rpm-4.2.1 development.jbj1-14/+14
CVS patchset: 6959 CVS date: 2003/11/23 19:50:52
2003-05-04Use getattro/setattro throughout.jbj1-7/+11
Convert to mpfprintlin from diddled mpprintln. CVS patchset: 6811 CVS date: 2003/05/04 17:34:53
2003-05-02Generate random primes method.jbj1-2/+2
CVS patchset: 6807 CVS date: 2003/05/02 21:05:46
2003-04-17Doxygen doco markup.jbj1-9/+9
CVS patchset: 6760 CVS date: 2003/04/17 17:17:27
2002-12-11Add iterators to rpmfts-py.c.jbj1-1/+1
splint fiddles. CVS patchset: 5933 CVS date: 2002/12/11 03:16:24
2002-12-11Add rpmfts-py.[ch] bindings for fts(3) from rpmio.jbj1-38/+130
splint fiddles. CVS patchset: 5932 CVS date: 2002/12/11 00:12:17
2002-12-10Add tp_{init,alloc,new,free} methods to rpmts.jbj1-1/+1
Use PyObject_{New,Del} consistently throughout. CVS patchset: 5931 CVS date: 2002/12/10 19:46:03
2002-12-04python: gilding lilies.jbj1-1/+1
CVS patchset: 5915 CVS date: 2002/12/04 02:01:47
2002-07-14- python: sanity check fixes on rpmts/rpmte methods.jbj1-2/+21
CVS patchset: 5554 CVS date: 2002/07/14 21:23:29
2002-06-03Teach doxygen about python/*-py.c files.jbj1-2/+2
Make sure that automake includes the python/test/* files. CVS patchset: 5461 CVS date: 2002/06/03 23:27:05
2002-05-28- eliminate legacy db methods, add ts.dbMatch method.jbj1-0/+1
CVS patchset: 5453 CVS date: 2002/05/28 23:06:44
2002-05-28- add rpmal/rpmte/rpmfd methods to bindings.jbj1-1/+1
- drop cpanflute and cpanflute2, will be in Chip's CPAN package now. CVS patchset: 5452 CVS date: 2002/05/28 16:22:42
2002-05-27Add bindings for rpmte and FD_t.jbj1-0/+215
CVS patchset: 5451 CVS date: 2002/05/27 21:40:08