[Rpm-maint] [PATCH] Fixed case conversion for hdr['filemodes']

Rakesh Pandit rakesh.pandit at gmail.com
Sat Apr 25 18:32:28 UTC 2009


There was a bug when we access filemodes via python rpm.

Test code to reproduce it:
import os
import rpm
ts = rpm.ts()
ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
fdno = os.open("<path/to/test/rpm/rpm-name.rpm>", os.O_RDONLY)
hdr = ts.hdrFromFdno(fdno)
print hdr["filemodes"]

This give values in -ve for many files e.g for one of files in
/home/rakesh/tryfolder/testrpms/dnrd-2.20.3-5.fc11.x86_64.rpm File:
/etc/dnrd/dnrd.conf number was -32348 were as correct number via
rpm -qp --qf "[%{filemodes} %{filenames}\n]"
/home/rakesh/tryfolder/testrpms/dnrd-2.20.3-5.fc11.x86_64.rpm

is 33188, now if we do 32348+33188 = 65536 and bingo! =)

May you review this one ?

Link: http://rakesh.fedorapeople.org/rpm/0005-Fixed-case-conversion-for-hdr-filemodes.patch

--
Regards,
Rakesh Pandit

>From b2784cc80e59daef761e56c25fa5d35a1218f573 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh at fedoraproject.org>
Date: Sat, 25 Apr 2009 23:43:59 +0530
Subject: [PATCH] Fixed case conversion for hdr['filemodes']
 - in hdr_subscript function for tag type RPM_INT16_TYPE.

---
 python/header-py.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/python/header-py.c b/python/header-py.c
index 8ec2cb4..f09a4f9 100644
--- a/python/header-py.c
+++ b/python/header-py.c
@@ -419,7 +419,7 @@ static PyObject * hdr_subscript(hdrObject * s,
PyObject * item)
 	if (count != 1 || forceArray) {
 	    metao = PyList_New(0);
 	    for (i = 0; i < count; i++) {
-		o = PyInt_FromLong(((short *) data)[i]);
+		o = PyInt_FromLong(((unsigned short *) data)[i]);
 		PyList_Append(metao, o);
 		Py_DECREF(o);
 	    }
-- 
1.6.0.6


More information about the Rpm-maint mailing list