Bug 1804625
Summary: | dnf crashes with an UTF-8 char in a repository filename | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 8 | Reporter: | Pavla Kratochvilova <pkratoch> | ||||||||
Component: | swig | Assignee: | Jitka Plesnikova <jplesnik> | ||||||||
Status: | CLOSED ERRATA | QA Contact: | RHEL CS Apps Subsystem QE <rhel-cs-apps-subsystem-qe> | ||||||||
Severity: | medium | Docs Contact: | |||||||||
Priority: | medium | ||||||||||
Version: | 8.1 | CC: | bnater, cbesson, jorton, jplesnik, kwalker, marek.schimara, pkratoch, swm-qe | ||||||||
Target Milestone: | rc | Keywords: | Patch, Reproducer, Triaged | ||||||||
Target Release: | 8.1 | ||||||||||
Hardware: | All | ||||||||||
OS: | Linux | ||||||||||
Whiteboard: | |||||||||||
Fixed In Version: | Doc Type: | If docs needed, set a value | |||||||||
Doc Text: | Story Points: | --- | |||||||||
Clone Of: | 1803038 | Environment: | |||||||||
Last Closed: | 2020-11-04 02:32:11 UTC | Type: | Bug | ||||||||
Regression: | --- | Mount Type: | --- | ||||||||
Documentation: | --- | CRM: | |||||||||
Verified Versions: | Category: | --- | |||||||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||||||
Cloudforms Team: | --- | Target Upstream Version: | |||||||||
Embargoed: | |||||||||||
Bug Depends On: | |||||||||||
Bug Blocks: | 1803038 | ||||||||||
Attachments: |
|
Description
Pavla Kratochvilova
2020-02-19 09:57:35 UTC
I belive this bug is fixed in upstream swig because of the following key change in files that were automatically generated by swig: Version 3.0.12: #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); // Note: This returns NULL if there is an exception raised by codec if(alloc) *alloc = SWIG_NEWOBJ; #endif PyBytes_AsStringAndSize(obj, &cstr, &len); // Note: This crashes if obj is NULL Version 4.0.1: #if !defined(SWIG_PYTHON_STRICT_BYTE_CHAR) if (!alloc && cptr) { /* We can't allow converting without allocation, since the internal representation of string in Python 3 is UCS-2/UCS-4 but we require a UTF-8 representation. TODO(bhy) More detailed explanation */ return SWIG_RuntimeError; } obj = PyUnicode_AsUTF8String(obj); if (!obj) return SWIG_TypeError; // Note: This fixes the bug. if (alloc) *alloc = SWIG_NEWOBJ; #endif PyBytes_AsStringAndSize(obj, &cstr, &len); Similar check after the PyUnicode_AsUTF8String call is on multiple places. Please let me know what additional information you need. Thank you for the report and your analysis. It was probably fixed by upstream with the commit commit b0e29fbdf31bb94b11cb8a7cc830b4a76467afa3 Author: William S Fulton <wsf.uk> Date: Mon Dec 4 18:41:55 2017 +0000 Add missing checks for failures in calls to PyUnicode_AsUTF8String. Previously a seg fault could occur when passing invalid UTF8 strings (low surrogates), eg passing u"\udcff" to the C layer (Python 3). https://github.com/swig/swig/commit/b0e29fbdf31bb94b11cb8a7cc830b4a76467afa3#diff-ba23eb3671d250e6a62261f19f653dd2 It is easy to backport. Created attachment 1664315 [details]
Backported upstream fix
It looks good to me. Created attachment 1674698 [details]
swig file
Created attachment 1674699 [details]
test file
Fixed in commit 7050872688c2f985d5fffd058f8230e20ab9d084 (HEAD -> stream-3.0-rhel-8.3.0, origin/stream-3.0-rhel-8.3.0) Author: Jitka Plesnikova <jplesnik> Date: Tue Apr 7 10:40:32 2020 +0200 Resolves: rhbz #1804625 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (swig:3.0 bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2020:4633 |