From ec8be9ed62b7f1ed730c81f88390d0c02329e6dc Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sat, 11 Feb 2006 20:14:06 +0000 Subject: [PATCH] * Fixed bug in dealing with symlinks (didn't work at all) * Fixed possible memory leak if reading of EA failed but buffer calculation didn't fail * Added and fixed Makefile after switched to subversion --- MANIFEST.in | 1 + Makefile | 20 ++++++++++++++++++++ NEWS | 7 +++++++ setup.py | 4 ++-- xattr.c | 11 +++++++---- 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 Makefile create mode 100644 NEWS diff --git a/MANIFEST.in b/MANIFEST.in index 20712af..b05fdcb 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,3 +5,4 @@ include xattr.txt include xattr.c include MANIFEST include ChangeLog +include NEWS diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..25693db --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +doc: xattr.txt xattr.html + +log: + rm -f ChangeLog + svn log | ~/bin/gnuify-changelog.pl > ChangeLog + +build/lib.linux-i686-2.3/xattr.so: xattr.c + ./setup.py build + +xattr.txt: build/lib.linux-i686-2.3/xattr.so + PYTHONPATH=build/lib.linux-i686-2.3 pydoc xattr > xattr.txt + +xattr.html: build/lib.linux-i686-2.3/xattr.so + PYTHONPATH=build/lib.linux-i686-2.3 pydoc -w xattr + +clean: + rm -f xattr.txt xattr.html + rm -rf build dist + +.PHONY: log clean diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..a04869c --- /dev/null +++ b/NEWS @@ -0,0 +1,7 @@ +News in 0.2.1 +------------- + + * fixed a bug when reading symlink EAs (you weren't able to + do it, actually) + * fix a possible memory leak when the actual read of the EA + failed but the call to get the length of the EA didn't diff --git a/setup.py b/setup.py index 1c8a36b..21dabec 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from distutils.core import setup, Extension long_desc = """This is a C extension module for Python which implements extended attributes manipulation. It is a wrapper on top of the attr C library - see attr(5).""" -version = "0.2" +version = "0.2.1" setup(name="pyxattr", version=version, @@ -18,5 +18,5 @@ setup(name="pyxattr", license="GPL", ext_modules=[Extension("xattr", ["xattr.c"], libraries=["attr"])], data_files=[("/usr/share/doc/pyxattr-%s" % version, - ["README", "xattr.html", "xattr.txt"])] + ["README", "NEWS", "xattr.html", "xattr.txt"])] ) diff --git a/xattr.c b/xattr.c index b4a7df7..14969b9 100644 --- a/xattr.c +++ b/xattr.c @@ -35,8 +35,8 @@ static PyObject * pygetxattr(PyObject *self, PyObject *args) { PyObject *myarg; - char *file; - int filedes, ishandle, dolink=0; + char *file = NULL; + int filedes = -1, ishandle, dolink=0; char *attrname; char *buf; int nalloc, nret; @@ -50,9 +50,9 @@ pygetxattr(PyObject *self, PyObject *args) /* Find out the needed size of the buffer */ nalloc = ishandle ? - fgetxattr(filedes, attrname, NULL, 0) : + fgetxattr(filedes, attrname, NULL, 0) : dolink ? - lgetxattr(file, attrname, NULL, 0) : + lgetxattr(file, attrname, NULL, 0) : getxattr(file, attrname, NULL, 0); if(nalloc == -1) { return PyErr_SetFromErrno(PyExc_IOError); @@ -67,8 +67,11 @@ pygetxattr(PyObject *self, PyObject *args) /* Now retrieve the attribute value */ nret = ishandle ? fgetxattr(filedes, attrname, buf, nalloc) : + dolink ? + lgetxattr(file, attrname, buf, nalloc) : getxattr(file, attrname, buf, nalloc); if(nret == -1) { + PyMem_Free(buf); return PyErr_SetFromErrno(PyExc_IOError); } -- 2.39.5