Bugs in dlls/wsock32/socket.c

Gerald Pfeifer gerald at pfeifer.com
Sat Nov 3 12:58:02 CDT 2007

dlls/wsock32/socket.c has the following code:

   DWORD routeTableSize, numRoutes, ndx, ret;

   numRoutes = min(routeTableSize - sizeof(MIB_IPFORWARDTABLE),
                   0) / sizeof(MIB_IPFORWARDROW) + 1;

The problem here is that both routeTableSize and sizeof(...) are of an
unsigned type, so their difference is also unsigned.  Which means that
the minimum between that difference and 0 always will be 0, the result
of the division will thus always be zero, and the result of the entire 
expressions is a constant 1.

I have a hunch this is not the intendend purpose of this code, is it? 
Gerald (Jerry) Pfeifer   gerald at pfeifer.com   http://www.pfeifer.com/gerald/

More information about the wine-devel mailing list