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

msilib.SummaryInfo.GetProperty() truncates the string by one character #45445

Closed
atuining mannequin opened this issue Sep 4, 2007 · 15 comments
Closed

msilib.SummaryInfo.GetProperty() truncates the string by one character #45445

atuining mannequin opened this issue Sep 4, 2007 · 15 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@atuining
Copy link
Mannequin

atuining mannequin commented Sep 4, 2007

BPO 1104
Nosy @loewis, @pfmoore, @amauryfa, @ericvsmith, @tjguk, @ezio-melotti, @berkerpeksag, @zware, @zooba, @uranusjr, @miss-islington
PRs
  • bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character #4517
  • [3.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11738
  • [3.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11738
  • [3.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11738
  • [3.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11738
  • [2.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11749
  • [2.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11749
  • [2.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) #11749
  • Files
  • _msi.patch2.txt
  • issue1104_msi_2.patch: Updated patch to fix and test off by one error in _msi.c
  • issue1104_msi_3.patch: fix typo of Ptyhon -> Python
  • 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 = 'https://github.com/zooba'
    closed_at = <Date 2019-02-19.03:14:43.094>
    created_at = <Date 2007-09-04.22:03:41.207>
    labels = ['3.7', '3.8', 'type-bug', 'library', 'OS-windows']
    title = 'msilib.SummaryInfo.GetProperty() truncates the string by one character'
    updated_at = <Date 2019-02-19.03:14:43.094>
    user = 'https://bugs.python.org/atuining'

    bugs.python.org fields:

    activity = <Date 2019-02-19.03:14:43.094>
    actor = 'steve.dower'
    assignee = 'steve.dower'
    closed = True
    closed_date = <Date 2019-02-19.03:14:43.094>
    closer = 'steve.dower'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2007-09-04.22:03:41.207>
    creator = 'atuining'
    dependencies = []
    files = ['8387', '21524', '21525']
    hgrepos = []
    issue_num = 1104
    keywords = ['patch']
    message_count = 15.0
    messages = ['55649', '111079', '132912', '132913', '132914', '134976', '137133', '306502', '306796', '306798', '334752', '334755', '334756', '334758', '335880']
    nosy_count = 13.0
    nosy_names = ['loewis', 'paul.moore', 'amaury.forgeotdarc', 'atuining', 'eric.smith', 'tim.golden', 'ezio.melotti', 'markm', 'berker.peksag', 'zach.ware', 'steve.dower', 'uranusjr', 'miss-islington']
    pr_nums = ['4517', '11738', '11738', '11738', '11738', '11749', '11749', '11749']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1104'
    versions = ['Python 2.7', 'Python 3.7', 'Python 3.8']

    @atuining
    Copy link
    Mannequin Author

    atuining mannequin commented Sep 4, 2007

    Attached is a patch that fixes the truncation of the property values
    returned by msilib.SummaryInfo.GetProperty(). Unfortunately Microsoft
    has deemed it necessary to return the size of the string without the
    null termination character but insists upon the size including it when
    passing it in. Arggh!

    @atuining atuining mannequin added the stdlib Python modules in the Lib dir label Sep 4, 2007
    @loewis loewis mannequin self-assigned this Sep 6, 2007
    @devdanzin devdanzin mannequin added the type-bug An unexpected behavior, bug, or error label Apr 7, 2009
    @amauryfa
    Copy link
    Member

    The patch looks correct, it's now a matter of unit tests.
    for example, I'd test the case where the length is around 1000..

    @markm
    Copy link
    Mannequin

    markm mannequin commented Apr 4, 2011

    I have updated the patch for current trunk (though no real changes required). I also include a testcase.

    One thing to review is that I added functionality to the tests to create the MSI to be tested. (felt this was safer than touching one of the ones under %systemroot%\installer.

    @ezio-melotti
    Copy link
    Member

    + path, msilib.schema, "Ptyhon Tests", "product_code", "1.0", "PSF")
    s/Ptyhon/Python/

    @markm
    Copy link
    Mannequin

    markm mannequin commented Apr 4, 2011

    And fix the typo... (thanks Ezio)

    @ericvsmith
    Copy link
    Member

    This patch seems okay to me, as far as it goes. I'd like to hear Martin's feedback, but I think it should be committed.

    And I realize the rest of this message doesn't apply to the patch, but it does address other problems in summary_getproperty(). At least one of these led to the original problem with the truncated character.

    1. It's not clear to me that the malloc() call only occurs if the type is VT_LPSTR. But that's the only case where free() is called. I think it would be better to move the call to free() to a cleanup section at the end of the function.

    2. The status is never checked for success, just for one specific failure. I think both calls to MsiSummaryInfoGetProperty should be looking for ERROR_SUCCESS.

    3. I don't think VT_FILETIME is special enough for its own error message. It should just be caught with all other unknown types.

    Maybe these last 3 should get their own new issue.

    @markm
    Copy link
    Mannequin

    markm mannequin commented May 28, 2011

    Responding to Eric's comments

    1. There are only three valid property types returned by MsiInteger, String & FILETIME. (http://msdn.microsoft.com/en-us/library/aa372045%28v=VS.85%29.aspx)

    2. That comment makes sense - I have entered a new issue (bpo-12202) for that.

    3. Per 1. - there shouldn't be any other unhandled types. I have entered issue bpo-12201 to track adding support for FILETIMEs.

    @BreamoreBoy BreamoreBoy mannequin added the OS-windows label May 6, 2015
    @ericvsmith
    Copy link
    Member

    Despite the fact that as of now (or 6+ years ago!) the only way to trigger the malloc() is via VT_LPSTR, I still think the way the free() call is written is bad. What if another type is added?

    If that were fixed, I still think the basic idea of this patch in isolation of the other raised issues is a good idea. If it was converted to a PR, I'd support merging it (although I'd like to hear from the Windows folks).

    But it is curious that this bug is so old and it hasn't caused more problems.

    @uranusjr
    Copy link
    Mannequin

    uranusjr mannequin commented Nov 23, 2017

    I have created a PR bpo-4517 from the patch. Would it be better to track the malloc problem in a new issue?

    As for why this never caused any problems… msilib is pretty standalone, and not one of the most used modules. It is also pretty trivial to roll your own solution with ctypes (or any FFI library), which is what I did when I hit this bug.

    @uranusjr
    Copy link
    Mannequin

    uranusjr mannequin commented Nov 23, 2017

    I made a shot to address the free() call. Hopefully this makes sense.

    @zooba
    Copy link
    Member

    zooba commented Feb 2, 2019

    I resolved some conflicts and will merge this once CI completes.

    If the backport to 2.7 isn't automatic then it may wait until someone else comes in to do it.

    @zooba zooba added 3.7 (EOL) end of life 3.8 only security fixes labels Feb 2, 2019
    @zooba zooba assigned zooba and unassigned loewis Feb 2, 2019
    @zooba
    Copy link
    Member

    zooba commented Feb 2, 2019

    New changeset 2de576e by Steve Dower (Tzu-ping Chung) in branch 'master':
    bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517)
    2de576e

    @zooba
    Copy link
    Member

    zooba commented Feb 2, 2019

    As expected, the 2.7 backport needs more work.

    Leaving this open for anyone who wants to handle it. I'll happily click merge for you if CI passes.

    @miss-islington
    Copy link
    Contributor

    New changeset 56f8411 by Miss Islington (bot) in branch '3.7':
    bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517)
    56f8411

    @miss-islington
    Copy link
    Contributor

    New changeset d5409eb by Miss Islington (bot) (Tzu-ping Chung) in branch '2.7':
    [2.7] bpo-1104: msilib.SummaryInfo.GetProperty() truncates the string by one character (GH-4517) (GH-11749)
    d5409eb

    @zooba zooba closed this as completed Feb 19, 2019
    @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
    3.7 (EOL) end of life 3.8 only security fixes OS-windows stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants