Bug 455024

Summary: python: Small python bz2 library interface and file object implementation fixes
Product: Red Hat Enterprise Linux 5 Reporter: Jan Lieskovsky <jlieskov>
Component: pythonAssignee: Dave Malcolm <dmalcolm>
Status: CLOSED WONTFIX QA Contact: Brock Organ <borgan>
Severity: low Docs Contact:
Priority: low    
Version: 5.3   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-03-14 21:36:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Lieskovsky 2008-07-11 14:47:39 UTC
Description of problem:

David Remahl discovered the following two bugs in the python bz2 library
interface and file object implementation

Proposed patch:

Index: Modules/bz2module.c
===================================================================
--- Modules/bz2module.c (revision 64642)
+++ Modules/bz2module.c (working copy)
@@ -525,7 +525,7 @@
                buffersize = Util_NewBufferSize((size_t)0);
        else
                buffersize = bytesrequested;
-       if (buffersize > INT_MAX) {
+       if (buffersize > PY_SSIZE_T_MAX) {
                PyErr_SetString(PyExc_OverflowError,
                                "requested number of bytes is "
                                "more than a Python string can hold");
Index: Objects/fileobject.c
===================================================================
--- Objects/fileobject.c        (revision 64642)
+++ Objects/fileobject.c        (working copy)
@@ -831,7 +831,6 @@
        long bytesrequested = -1;
        size_t bytesread, buffersize, chunksize;
        PyObject *v;
-
        if (f->f_fp == NULL)
                return err_closed();
        /* refuse to mix with f.next() */
@@ -845,6 +844,7 @@
                buffersize = new_buffersize(f, (size_t)0);
        else
                buffersize = bytesrequested;
+
        if (buffersize > PY_SSIZE_T_MAX) {
                PyErr_SetString(PyExc_OverflowError,
        "requested number of bytes is more than a Python string can hold");
@@ -1075,7 +1075,7 @@
         * into its buffer.
         */
        total_v_size = MAXBUFSIZE << 1;
-       v = PyString_FromStringAndSize((char*)NULL, (int)total_v_size);
+       v = PyString_FromStringAndSize((char*)NULL, total_v_size);
        if (v == NULL)
                return v;
        /* copy over everything except the last null byte */
@@ -1130,7 +1130,7 @@
                        Py_DECREF(v);
                        return NULL;
                }
-               if (_PyString_Resize(&v, (int)total_v_size) < 0)
+               if (_PyString_Resize(&v, (Py_ssize_t)total_v_size) < 0)
                        return NULL;
                /* overwrite the trailing null byte */
                pvfree = BUF(v) + (prev_v_size - 1);

Comment 2 RHEL Program Management 2013-03-14 21:36:10 UTC
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.