Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonsense errors reported by msilib.FCICreate for bad argument #66130

Closed
JeffreyArmstrong mannequin opened this issue Jul 7, 2014 · 12 comments
Closed

Nonsense errors reported by msilib.FCICreate for bad argument #66130

JeffreyArmstrong mannequin opened this issue Jul 7, 2014 · 12 comments
Labels
extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error

Comments

@JeffreyArmstrong
Copy link
Mannequin

JeffreyArmstrong mannequin commented Jul 7, 2014

BPO 21931
Nosy @loewis, @tjguk, @ezio-melotti, @bitdancer, @zware, @zooba
Files
  • _msi.3.4.0.patch: patch for Python 3.4.0
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-05-18.05:57:32.221>
    created_at = <Date 2014-07-07.12:53:10.675>
    labels = ['extension-modules', 'type-bug', 'OS-windows']
    title = 'Nonsense errors reported by msilib.FCICreate for bad argument'
    updated_at = <Date 2015-05-18.05:57:32.220>
    user = 'https://bugs.python.org/JeffreyArmstrong'

    bugs.python.org fields:

    activity = <Date 2015-05-18.05:57:32.220>
    actor = 'zach.ware'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-05-18.05:57:32.221>
    closer = 'zach.ware'
    components = ['Extension Modules', 'Windows']
    creation = <Date 2014-07-07.12:53:10.675>
    creator = 'Jeffrey.Armstrong'
    dependencies = []
    files = ['35935']
    hgrepos = []
    issue_num = 21931
    keywords = ['patch']
    message_count = 12.0
    messages = ['222458', '222853', '222883', '223206', '226597', '230583', '230616', '230656', '243405', '243415', '243457', '243459']
    nosy_count = 8.0
    nosy_names = ['loewis', 'tim.golden', 'ezio.melotti', 'r.david.murray', 'python-dev', 'zach.ware', 'steve.dower', 'Jeffrey.Armstrong']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue21931'
    versions = ['Python 3.4', 'Python 3.5']

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented Jul 7, 2014

    The function fcicreate in PC/_msi.c can return nonsense if the list of files passed to msilib.FCICreate does not contains tuples as expected. To replicate,

    import msilib
    msilib.FCICreate("test.cab", ["entry.txt"])

    The above code will return a ValueError of the format:

    ValueError: FCI error 11260524

    The error code is meaningless. If one were to examine the code, you can see in PC/_msi.c:246 (in "current"):

        if (!PyArg_ParseTuple(item, "ss", &filename, &cabname))
            goto err;
    

    If we look at the error handler at PC/_msi.c:262, it assumes that one of the Windows MSI API calls had failed, and will print the contents of the ERF error structure:

    err:
    PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); /* XXX better error type */

    In the case where the list does not contain tuples, the value of erf.erfOper was never initialized or set because the error being raised is not due to the Windows MSI API. The error is highly misleading as it is simply an argument error.

    @JeffreyArmstrong JeffreyArmstrong mannequin added extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error labels Jul 7, 2014
    @ezio-melotti
    Copy link
    Member

    Do you want to propose a patch?

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented Jul 12, 2014

    Attached a patch. The dangers of using goto...

    @bitdancer
    Copy link
    Member

    mslib doesn't have many tests, but it looks like it would be easy enough to add one for this?

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented Sep 8, 2014

    Is this patch going to be accepted? It fixes actual incorrect code in msilib, and it seems to have stagnated

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Nov 4, 2014

    I haven't had any time to work on Python in the last year, so it may take some more time for me to look into this.

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented Nov 4, 2014

    There's not much to look into. If the Python function encounters an argument error, it returns an uninitialized integer as an "error code." This patch fixes incorrect C code, nothing more.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Nov 4, 2014

    Right, the entire patch might be processed in 30 minutes. I won't have these 30 minutes any time soon.

    @JeffreyArmstrong
    Copy link
    Mannequin Author

    JeffreyArmstrong mannequin commented May 17, 2015

    I thought, while I'm here reporting another bug, I'd bump this once more.

    There is a patch here, and it corrects clearly broken code. Should I mark this as "won't fix?"

    @zware
    Copy link
    Member

    zware commented May 17, 2015

    I'll try to have a look at this later today, but unfortunately can't
    guarantee anything (I don't know C, MSI, or _msi very well).

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 18, 2015

    New changeset 41281737d71a by Zachary Ware in branch '3.4':
    Issue bpo-21931: Fix error handling in msilib.FCICreate().
    https://hg.python.org/cpython/rev/41281737d71a

    New changeset cb0d1d86215e by Zachary Ware in branch 'default':
    Closes bpo-21931: Merge with 3.4
    https://hg.python.org/cpython/rev/cb0d1d86215e

    @python-dev python-dev mannequin closed this as completed May 18, 2015
    @zware
    Copy link
    Member

    zware commented May 18, 2015

    It's a simple enough fix, so I went ahead and committed it. Thanks for the patch!

    I've created bpo-24224 to track the addition of tests to test_msilib (for more than just this issue).

    @zware zware reopened this May 18, 2015
    @zware zware closed this as completed May 18, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants