classification
Title: msilib.SummaryInfo.GetProperty() truncates the string by one character
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.2, Python 3.1, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: loewis Nosy List: amaury.forgeotdarc, atuining, eric.smith, ezio.melotti, loewis, markm
Priority: normal Keywords: patch

Created on 2007-09-04 22:03 by atuining, last changed 2011-05-28 14:00 by markm.

Files
File name Uploaded Description Edit
_msi.patch2.txt atuining, 2007-09-04 22:03
issue1104_msi_2.patch markm, 2011-04-04 01:58 Updated patch to fix and test off by one error in _msi.c review
issue1104_msi_3.patch markm, 2011-04-04 02:38 fix typo of Ptyhon -> Python review
Messages (7)
msg55649 - (view) Author: Anthony Tuininga (atuining) Date: 2007-09-04 22:03
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!
msg111079 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-07-21 15:58
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..
msg132912 - (view) Author: Mark Mc Mahon (markm) * Date: 2011-04-04 01:58
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.
msg132913 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-04-04 02:02
+        path, msilib.schema, "Ptyhon Tests", "product_code", "1.0", "PSF")
s/Ptyhon/Python/
msg132914 - (view) Author: Mark Mc Mahon (markm) * Date: 2011-04-04 02:38
And fix the typo... (thanks Ezio)
msg134976 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2011-05-02 14:31
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.
msg137133 - (view) Author: Mark Mc Mahon (markm) * Date: 2011-05-28 14:00
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 (issue12202) for that.

3. Per 1. - there shouldn't be any other unhandled types. I have entered issue issue12201 to track adding support for FILETIMEs.
History
Date User Action Args
2011-05-28 14:00:42markmsetmessages: + msg137133
2011-05-02 14:31:37eric.smithsetnosy: + eric.smith
messages: + msg134976
2011-04-04 02:38:43markmsetfiles: + issue1104_msi_3.patch

messages: + msg132914
2011-04-04 02:02:46ezio.melottisetnosy: + ezio.melotti

messages: + msg132913
stage: test needed -> patch review
2011-04-04 01:58:42markmsetfiles: + issue1104_msi_2.patch

nosy: + markm
messages: + msg132912

keywords: + patch
2010-07-21 15:58:38amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg111079
2010-07-10 15:50:09BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 3.0
2009-04-07 04:04:42ajaksu2setstage: test needed
type: behavior
versions: + Python 2.6, Python 3.0, - Python 2.5
2007-09-17 08:24:13jafosetpriority: normal
2007-09-06 07:45:49loewissetassignee: loewis
nosy: + loewis
2007-09-04 22:03:41atuiningcreate