RE: BUG in Kannel Wapbox

"Bjoern Buettner" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAlWqFtjr/Iki9rftBfYS1ysKAAAAQAAAA/jhSst6FmU+DFdgmxBEO/[email protected]>
Hi list,

Have fixed a BUG in gwlib/protected.c in line 99:.
For detailed problem description see in the list the subject of this
mail .

The main problem is the return code of 0 in the original file, it should
be -1.
Is the return code 0 so Kannel loops in a "state RESULT_WAIT, event
Timedout-A".
The wrong IP "192.1.1/foobar.wml" is not recognised as wrong IP, kannel
trys to lookup it in a loop.

The wrong IP "192.1.1./fobar.wml" is recognised as wrong IP and kannel
says "http lookup failed, oops" that's ok. [important is the last dot in
the IP.]

This rewritten code will fix that problem.

Cheers Bjoern


Here is that fixed part (it is not really nice programmed, I know, I'm
not a "C" programmer but it works, it was my first time :-))))

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gwlib/protected.c [FIXED BUG]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/*
 *
 * FIXME :: BUG gethostbyname 
 *
 */
    int ret;
    struct hostent *p;
                             /*
    int oct1,oct2,oct3,oct4;  * IP addr. 
                              */ 
    int valid;                

    valid=1;

    sscanf(name,"%d.%d.%d.%d",&oct1,&oct2,&oct3,&oct4);

    if ((oct1<0) || (oct1>255) || (oct1 == NULL)) { valid=0; }
    if ((oct2<0) || (oct2>255) || (oct2 == NULL)) { valid=0; }
    if ((oct3<0) || (oct3>255) || (oct3 == NULL)) { valid=0; }
    if ((oct4<0) || (oct4>255) || (oct4 == NULL)) { valid=0; }
    
    /* 
     * failed to get hostname or ip and die
     */
    if (valid==0) {
       ret = -1;
       return ret;
    
    }

    lock(GETHOSTBYNAME);
    p = gethostbyname(name);
    if ((p == NULL))
        ret = -1;
    else {
        ret = 0;
        *ent = *p;
    }
    unlock(GETHOSTBYNAME);
    return ret;
}

###########################################


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gwlib/protected.c [ORIGINAL]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
    int ret;
    struct hostent *p;

    lock(GETHOSTBYNAME);
    p = gethostbyname(name);
    if (p == NULL)
        ret = -1;
    else {
        ret = 0;
        *ent = *p;
    }
    unlock(GETHOSTBYNAME);
    return ret;
}

#############################################




kind regards

Bjoern Buettner
Vodafone Information Systems GmbH
Daniel-Goldbach-Str. 17-19 
D-40880 Ratingen
Tel.:    +49-2102-97-2013
Fax:     +49-2102-97-1310
mailto:  [email protected]
http://www.vodafone.com
http://www.vodafone-is.de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.