Hi,
Is it a bug in the WINE gethostbyname (WS_gethostbyname) implementation, where if the arg name is of string length 0, then it returns unsuccessful.
I have experience this issue with a Windows program (Onkyo Nettune) where the hostname passed to gethostbyname is of length 0. (This seems to be a bug in the program itself). However, the program works okay in native Windows.
There seems to be a check in the gethostbyname for a NULL arg name ... if(!name) ... But no check for ... if(!strlen(name)) ....
I have tested the strlen check and it seems to work and satisfies the Windows program.
Does the above make sense, as I am not a programmer? Not sure if this s bug in wine even though it implementation should be matching Windows native.
Thanks, Phil
On 1/29/06, Phil Goss pagoss@gmail.com wrote:
Hi,
Is it a bug in the WINE gethostbyname (WS_gethostbyname) implementation, where if the arg name is of string length 0, then it returns unsuccessful.
...
I have tested the strlen check and it seems to work and satisfies the Windows program.
This would make a good regression test. See:
http://winehq.org/site/docs/winedev-guide/testing
-- James Hawkins
Am Sonntag, den 29.01.2006, 14:46 +0100 schrieb Phil Goss:
There seems to be a check in the gethostbyname for a NULL arg name ... if(!name) ... But no check for ... if(!strlen(name)) ....
Alexandre changed "strlen(xxx) > 0" in my first Patch to xxx[0] So for your code above, simple change:
if(!name) {
to
if((!name) && (name[0])) {
The logic is the same: use the code-path, if name is NULL and use it also, when the string is empty.
I send this type of patch yesterday and it's already in the tree.
The Commit-Message is here: http://www.winehq.org/pipermail/wine-cvs/2006-February/020657.html
(i used (pName != NULL) to have a common style in this function)
Does the above make sense, as I am not a programmer?
Yes, it does, and it's important when we have a Program that depend on this behaviour.
Not sure if this s bug in wine even though it implementation should be matching Windows native.
That's also a reason, why we have the Testsuite. A specific Test changes "should match" to "does not match (yet)" or "matches all the cases we tested".
The winedev-guide is nice to read. (see msg from James)
Detlef Riekenberg wrote:
if((!name) && (name[0])) {
Do you really mean that? "if name is 0, then dereference name"?
-- Christer Palm
This is what seems to have worked for me
if(!name || !strlen(name)) {
On Fri, 03 Feb 2006 19:23:22 +0100, Christer Palm palm@nogui.se wrote:
Detlef Riekenberg wrote:
if((!name) && (name[0])) {
Do you really mean that? "if name is 0, then dereference name"?
-- Christer Palm
On 2/3/06, Phil Goss pagoss@gmail.com wrote:
This is what seems to have worked for me
if(!name || !strlen(name)) {
The shortest way to do this is:
if (!name || !*name) {
-- James Hawkins
Am Samstag, den 04.02.2006, 00:59 +0100 schrieb Phil Goss:
This is what seems to have worked for me
if(!name || !strlen(name)) {
strlen() is overkill here, because you do not need the real length of the string.
So "!name[0]" (or "!*name") instead of "!strlen(name)" is more efficient, when you want to check for an empty name.
On 2/8/06, Detlef Riekenberg wine.dev@web.de wrote:
Am Freitag, den 03.02.2006, 19:23 +0100 schrieb Christer Palm:
if((!name) && (name[0])) {
Do you really mean that? "if name is 0, then dereference name"?
No. the code is:
"if name is not NULL, then dereference name"
Consider the case when name is NULL:
!name = TRUE
if (TRUE && name[0])
So the only time you'll dereference name is when name is NULL. It should read:
if (name && name[0])
-- James Hawkins
Thanks,
So basically, this check is now taken care of in the latest patches, correct?
Good ... Ill take a look at the guide as James suggested.
Cheers, Phil
On Wed, 01 Feb 2006 23:27:53 +0100, Detlef Riekenberg wine.dev@web.de wrote:
Am Sonntag, den 29.01.2006, 14:46 +0100 schrieb Phil Goss:
There seems to be a check in the gethostbyname for a NULL arg name ... if(!name) ... But no check for ... if(!strlen(name)) ....
Alexandre changed "strlen(xxx) > 0" in my first Patch to xxx[0] So for your code above, simple change:
if(!name) {
to
if((!name) && (name[0])) {
The logic is the same: use the code-path, if name is NULL and use it also, when the string is empty.
I send this type of patch yesterday and it's already in the tree.
The Commit-Message is here: http://www.winehq.org/pipermail/wine-cvs/2006-February/020657.html
(i used (pName != NULL) to have a common style in this function)
Does the above make sense, as I am not a programmer?
Yes, it does, and it's important when we have a Program that depend on this behaviour.
Not sure if this s bug in wine even though it implementation should be matching Windows native.
That's also a reason, why we have the Testsuite. A specific Test changes "should match" to "does not match (yet)" or "matches all the cases we tested".
The winedev-guide is nice to read. (see msg from James)