Hi,
As I am currently testing xmail for a custom setup over here, I ran into 
several issues, one of which was/is the SMTP-POP3 auth mechanism.

Using 1.25-pre22 (downloaded from link presented on this ML earlier).

Turns out that the code as is should've never worked; at it it won't 
ever on my system (using unitialized vars). See below for PART of the fix:

diff -u -EbwB --strip-trailing-cr -x resource.h -x '*.rc' -x '*.aps' -x 
VERSION.txt -x '*.ds*' -x '*.vcproj' -x '*.s*' -x '*.user' -x '*.ncb' -x 
'*.o' -x '*I_A*' -x '*.sh' ../../1original/xmail/POP3Utils.cpp 
../POP3Utils.cpp
--- ../../1original/xmail/POP3Utils.cpp    2007-11-02 01:34:32.000000000 
+0100
+++ ./POP3Utils.cpp    2007-11-15 01:11:07.000000000 +0100
@@ -1542,10 +1546,15 @@
     fclose(pIpFile);
 
     /* Do IP matching */
-    SYS_INET_ADDR PrevAddr, CurrAddr;
+    AddressFilter PrevAddr /* , CurrAddr */;
 
-    if (SysGetHostByName(szIP, SysGetAddrFamily(CurrAddr), PrevAddr) < 0 ||
-        !SysSameAddress(PrevAddr, CurrAddr)) {
+    ZeroData(PrevAddr);
+    /* make sure the mask is all 1's */
+    memset(&PrevAddr.Mask, 0xFF, sizeof(PrevAddr.Mask));
+
+    if (SysGetHostByName(szIP, SYS_INET46 /* SysGetAddrFamily(CurrAddr) 
*/, PrevAddr.Addr) < 0 ||
+        pPeerInfo == NULL ||
+        !MscAddressMatch(PrevAddr, *pPeerInfo /* CurrAddr */)) {
         ErrSetErrorCode(ERR_NO_POP3_IP);
         return ERR_NO_POP3_IP;
     }

The original call to 'SysGetAddrFamily()' up there will always return 
bogus/garbled results, which will screw up the behaviour of 
SysGetHostByName().
Then, now that you'll pass that first check, SysSameAddress() wont ever 
work, because it'll compare the _complete_ struct, i.e. _with_ port 
number and other stuff included, hence peerInfo (which includes port 
used) and prevAddr (which is only the translated IP address) will never 
match.
However, xmail already has a very similar routine MscAddressMatch() 
which ignores the port number as it should right here. Hence that part 
of the change.

If you test this little piece of code, you'll notice that peerInfo 
content is partly garbled. That's because the SYS_INET_ADDR variables 
declared here and elsewhere in the code aren't always zeroed. (Which 
also applies to structs which include one or more SYS_INET_ADDR elements.)

For a complete diff of the fix, see the attached file (which is 
compressed using 7zip: see also www.7zip.org).
Source code has been reviewed to make sure all of those SYS_INET_ADDR 
ZeroData() calls were present.



Also included in the diff:

- a few minor memleak fixups when error messages are printed.
- fix for spurious xmail crash when starting the debug build on Win32 
platforms. (Note that this fix is not complete yet: under certain 
circumstances the semaphore hook is called AFTER the data has been 
deallocated. A quick hack is obvious, but I'm looking for the reason why 
this is happening, as there might be something festering deep down below.)



Tested (but only cursory) on WinXP/AMD. Code compiled using MSVC2005SP1.
NOT tested (yet) on Linux/other platforms.



I hope this is useful for y'all and Davide likes the changes enough to 
include them in the code.
There's more where this came from. ;-)

Best regards,

Ger





-- Binary/unsupported file stripped by Ecartis --
-- Type: application/octet-stream
-- File: i_a-pre22.SMTP-POP3-auth.20071115.unified.diff.7z


-
To unsubscribe from this list: send the line "unsubscribe xmail" in
the body of a message to [EMAIL PROTECTED]
For general help: send the line "help" in the body of a message to
[EMAIL PROTECTED]

Reply via email to