KERNEL: PeekNamedPipe must check for zero-length buffer as well as for NULL buffer

Alex Villaci­s Lasso a_villacis at palosanto.com
Tue Mar 22 11:25:21 CST 2005


This patch was made in an attempt to solve bug 2474 
(http://bugs.winehq.org/show_bug.cgi?id=2474).

The application MP3GainGui.exe (a GUI frontend for mp3gain, written in 
Visual Basic) exhibits several problems when run in Wine. The first one 
was a cryptic error message claiming that mp3gain.exe was not found, 
even when the file was present. The problem was traced down to an 
inability to perform a zero-length peek in a pipe via recv(). The 
attempt to do so fails with errno 95 (Operation not supported). However, 
from the examination of the source code of MP3GainGui, it is apparent 
that PeekNamedPipe is called with the sole purpose of checking whether 
any data is available. So it was (correctly) indicating a NULL buffer 
and a buffer length of zero. Because of some VisualBasic oddity, the 
intended NULL was not transmitted to Wine, and instead appeared as an 
(invalid) non-NULL address, along with the zero buffer-length. The 
PeekNamedPipe() function then examined the buffer pointer, assumed it 
was valid, and proceeded to perform the recv() with the lesser of 
(available,buffer-length)--> 0. Hence the error. IMHO, PeekNamedPipe() 
should not attempt a zero-length peek, even if it was supported (which 
is not). So here is the patch.

Changelog:
* PeekNamedPipe now checks both for a NULL buffer and a zero-length 
buffer before trying to recv() from the pipe


-------------- next part --------------
A non-text attachment was scrubbed...
Name: wine-kernel-PeekNamedPipe-no-zero-read.patch
Type: text/x-patch
Size: 718 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20050322/23eebff0/wine-kernel-PeekNamedPipe-no-zero-read.bin


More information about the wine-patches mailing list