From a37fdf32f3acc611af95410d25005e7bfb645454 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Thu, 3 Jan 2013 21:36:36 +0100 Subject: [PATCH] Fix string/unicode buffer size parsing It seems that CPython allows passing "wrong" pointers for et# (Py_ssize_t instead of int), but PyPy has problems with this, and wrongly casts the pointers, leading to unsigned/signed conversion failures. This bug was introduced in commits 433c5852 and 8aa6fd81; I'm no longer sure why bufsize was changed from int to Py_ssize_t as well, but passing an int value to a C function expecting an ssize_t should be safe as the compiler should do the required conversions behind the scenes (as long as it has correct information about the types). Closes gh-1. --- xattr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xattr.c b/xattr.c index f88d116..57257bb 100644 --- a/xattr.c +++ b/xattr.c @@ -1,7 +1,7 @@ /* xattr - a python module for manipulating filesystem extended attributes - Copyright (C) 2002, 2003, 2006, 2008, 2012 Iustin Pop + Copyright (C) 2002, 2003, 2006, 2008, 2012, 2013 Iustin Pop This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -593,7 +593,7 @@ pysetxattr(PyObject *self, PyObject *args) int nofollow = 0; char *attrname = NULL; char *buf = NULL; - Py_ssize_t bufsize; + int bufsize; int nret; int flags = 0; target_t tgt; @@ -659,7 +659,7 @@ xattr_set(PyObject *self, PyObject *args, PyObject *keywds) int nofollow = 0; char *attrname = NULL; char *buf = NULL; - Py_ssize_t bufsize; + int bufsize; int nret; int flags = 0; target_t tgt; -- 2.39.5