Bug 479417 - xattr fails if filename is unicode object
xattr fails if filename is unicode object
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: pyxattr (Show other bugs)
12
All Linux
low Severity medium
: ---
: ---
Assigned To: Marcin Zajaczkowski
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2009-01-09 08:48 EST by John Dennis
Modified: 2010-02-01 20:07 EST (History)
1 user (show)

See Also:
Fixed In Version: 0.5.0-1.fc12
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-02-01 20:07:56 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
handle unicode strings (3.73 KB, patch)
2009-01-09 08:48 EST, John Dennis
no flags Details | Diff

  None (edit)
Description John Dennis 2009-01-09 08:48:29 EST
Created attachment 328544 [details]
handle unicode strings

The first parameter passed into any of the xattr calls may be either a filename or a file object. However if the filename is a unicode string rather than a str object the functions fail producing the error:

argument 1 must be string or int

even though the argument is a string. This occurs due to the convertObj function which only checks for str objects. Normally the str vs. unicode handling would be taken care of by PyArg_ParseTuple, but because the first arg may be a variety of object types the PyArg_ParseTuple logic is bypassed and instead convertObj is called on the first parameter.

If PyArg_ParseTuple had been passed a format specifier of 's' for the first arg then a unicode object would have been encoded to a C string using the default encoding. There are other string functions which can be called directly on a PyObject string which will return a decoded C string using the default encoding, however even though the default encoding will work most of the time for filenames it is not technically the right encoding, one should use the encoding specified for the file system (Py_FileSystemDefaultEncoding, see the posix module for examples).

When you decode a unicode object to something other than the default encoding the decoded C string is malloc'ed and must be freed (see the documentation of the 'e' format conversion specifiers for PyArg_ParseTuple and it's implementation in the posix module).

I have fixed the above problems and provided a patch which is attached.

The patch works by modifying convertObj to check for both str objects and unicode objects. In both cases the filename returned through the filename pointer parameter is malloc'ed string which the caller must free. In the case of a unicode object it is decoded using the Py_FileSystemDefaultEncoding. I also updated each location where convertObj is called to free the filename string.
Comment 1 Marcin Zajaczkowski 2009-01-09 10:35:43 EST
Thank you John for your report and a patch.

I think it would be better to merge it upstream and I sent it to the author:
https://sourceforge.net/tracker/index.php?func=detail&aid=2495931&group_id=69931&atid=526201

I suggest to wait for his feedback to decide does it make sense to release the next version of RPM or wait for the next version of pyxattr.
Comment 2 Bug Zapper 2009-11-18 05:42:42 EST
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 3 Marcin Zajaczkowski 2009-12-28 15:24:22 EST
Hello again John!

Yesterday I've got a notification from pyxattr's author about a new version which should solve a problem with unicode strings (he has missed previous bug reports :) ). I've made packages which are available from my webpage:
http://timeoff.wsisiz.edu.pl/rpms/pyxattr/pyxattr-0.5.0-1.fc11.i586.rpm
http://timeoff.wsisiz.edu.pl/rpms/pyxattr/pyxattr-0.5.0-1.src.rpm (in case you have Fedora 12 or use another architecture and need to rebuild)

Could you check if that works for you?
(then I would put in into normal Fedora package repository)

Marcin
Comment 4 John Dennis 2010-01-04 11:21:38 EST
A very quick check on F-12 after building from the srpm seems to indicate this is working. I also did a quick check on how the C file was coded and it seems fine as well.
Comment 5 Fedora Update System 2010-01-14 15:40:15 EST
pyxattr-0.5.0-1.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/pyxattr-0.5.0-1.fc12
Comment 6 Fedora Update System 2010-01-15 17:06:47 EST
pyxattr-0.5.0-1.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update pyxattr'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-0587
Comment 7 Fedora Update System 2010-02-01 20:07:49 EST
pyxattr-0.5.0-1.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.