classification
Title: _winreg.QueryValue fault while reading mangled registry values
Type: behavior Stage:
Components: Library (Lib), Windows Versions: Python 2.6, Python 2.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: brian.curtin, gagenellina, malicious.wizard (3)
Priority: Keywords patch

Created on 2008-12-22 15:06 by malicious.wizard, last changed 2009-11-14 17:28 by gagenellina.

Files
File name Uploaded Description Edit Remove
issue4722_20091104_v1.patch brian.curtin, 2009-11-05 03:40 Patch against r76116
Messages (5)
msg78190 - (view) Author: Alex (malicious.wizard) Date: 2008-12-22 15:06
== What steps will reproduce the problem?
1. Create registry key (let's assume it's located in
HKEY_CURRENT_USER\TestKey);
2. Walk to it in "regedit";
3. Right-click on "(Default)" and select "Modify binary data";
4. Leave everything blank and press "OK";
5. Go to Python and execute this:
>>> import _winreg
>>> _winreg.QueryValue(_winreg.HKEY_CURRENT_USER, 'TestKey')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: ..\Objects\stringobject.c:4271: bad argument to internal
function

== What is the expected output? What do you see instead?
I expect either returning "''" or some ValueError indicating that source
string is malformed.

== What version of the product are you using? On what operating system?
1. Windows XP Professional SP2 English;
2. Tested on Python 2.5.2;
3. Tested on Python 2.6.1;
4. Tested on Stackless Python 2.5.2.

== Please provide any additional information below.
And yes, I know that this function is lame and everybody using it also
is lame, but it's not really a reason to include buggy functions, right?
msg94917 - (view) Author: Brian Curtin (brian.curtin) Date: 2009-11-05 03:40
The attached patch will return "" in the case that Alex describes.
However, I haven't been able to reproduce his actions outside of
manually running the steps, so I don't have a test written for it.
Anyone know how to reproduce it from code?
msg95009 - (view) Author: Gabriel Genellina (gagenellina) Date: 2009-11-07 05:44
I cannot reproduce this bug with the current 2.6.4 release - it is 
either fixed or masked now.
msg95026 - (view) Author: Brian Curtin (brian.curtin) Date: 2009-11-07 20:40
It happens to me on trunk with Windows XP. I also have access to Windows
Server 2003 where I can test this (haven't yet). Which version are you
running that you don't see this issue?
msg95246 - (view) Author: Gabriel Genellina (gagenellina) Date: 2009-11-14 17:28
I've noticed this depends on the user privileges. When logged in as a 
normal user, I get the internal error as originally reported. When 
logged in as an administrator, there is no error and I get an empty 
string.
History
Date User Action Args
2009-11-14 17:28:26gagenellinasetmessages: + msg95246
2009-11-07 20:40:07brian.curtinsetmessages: + msg95026
2009-11-07 05:44:22gagenellinasetmessages: + msg95009
2009-11-05 03:40:25brian.curtinsetfiles: + issue4722_20091104_v1.patch

nosy: + brian.curtin
messages: + msg94917

keywords: + patch
2008-12-26 19:55:30gagenellinasetnosy: + gagenellina
2008-12-22 15:06:31malicious.wizardcreate