Fixed password_callback so it obtains UTF-8 password correctly (bug #1155469).

Resolves: rhbz#1155469
This commit is contained in:
Tim Waugh 2014-12-13 00:06:44 +00:00
parent 3470d0478c
commit 0bdb663e2d
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,35 @@
diff -up pycups-1.9.69/cupsconnection.c.pw-callback pycups-1.9.69/cupsconnection.c
--- pycups-1.9.69/cupsconnection.c.pw-callback 2014-06-20 15:13:07.000000000 +0100
+++ pycups-1.9.69/cupsconnection.c 2014-12-13 00:05:00.559619993 +0000
@@ -1,6 +1,6 @@
/*
* cups - Python bindings for CUPS
- * Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Red Hat, Inc
+ * Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013, 2014 Red Hat, Inc
* Author: Tim Waugh <twaugh@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -362,7 +362,6 @@ password_callback (int newstyle,
Connection *self = NULL;
PyObject *args;
PyObject *result;
- const char *pwval;
int i;
debugprintf ("-> password_callback for http=%p, newstyle=%d\n",
@@ -403,13 +402,9 @@ password_callback (int newstyle,
}
free (self->cb_password);
- if (result == Py_None)
+ if (result == Py_None ||
+ !UTF8_from_PyObj (&self->cb_password, result))
self->cb_password = NULL;
- else
- {
- pwval = PyBytes_AsString (result);
- self->cb_password = strdup (pwval);
- }
Py_DECREF (result);
if (!self->cb_password || !*self->cb_password)

View File

@ -6,9 +6,10 @@
Summary: Python bindings for CUPS
Name: python-cups
Version: 1.9.69
Release: 1%{?dist}
Release: 2%{?dist}
URL: http://cyberelk.net/tim/software/pycups/
Source: http://cyberelk.net/tim/data/pycups/pycups-%{version}.tar.bz2
Patch1: python-cups-pw-callback.patch
License: GPLv2+
Group: Development/Languages
BuildRequires: cups-devel
@ -40,6 +41,7 @@ Documentation for python-cups.
%prep
%setup -q -n pycups-%{version}
%patch1 -p1 -b .pw-callback
rm -rf %{py3dir}
cp -a . %{py3dir}
@ -81,6 +83,10 @@ popd
%doc examples html
%changelog
* Sat Dec 13 2014 Tim Waugh <twaugh@redhat.com> - 1.9.69-2
- Fixed password_callback so it obtains UTF-8 password correctly
(bug #1155469).
* Thu Dec 4 2014 Tim Waugh <twaugh@redhat.com> - 1.9.69-1
- 1.9.69.