Hi,
I discovered the fatal bug in andns.
I'll write here the code for the correction, coz cvs is down :/
Two bugs:
*
**
*** 1- andns.c:236 ns_general_send()
**
*
The value returned by `ai_send_recv_close()` has to be tested
differently. The SEGFAULT is due to this bug (ai_send_recv_close()
returns -2, but the value is tested only vs -1).
The second bug is the reason for the -2 return value (see after)
Replace the entire function with:
########## BEGIN CODE ########################################
int ns_general_send(char *msg,int msglen,char *answer,int anslen) {
int res,i;
char buf[2000];
for (i=0; i<_andns_ns_count_;i++) {
res=ai_send_recv_close(_andns_ns_[i],msg,msglen,
answer,anslen,0,0,ANDNS_TIMEOUT);
if (res<0) {
if (res==-1) {
err_ret(ERR_SKTCON,-1);}
else if (res==-2) {
err_ret(ERR_SKTSEN,-1);}
else if (res==-3) {
err_ret(ERR_SKTREC,-1);}
}
else
return res;
}
return 0;
}
######### END CODE ############################
*
**
*** 2 - andns_net.c:180 w_recv_timeout(), w_send_timeout()
**
*
This bug is very, very, very, ...., strange.
ai_send_recv_close returns -2.
In both function, there's a call to select(), but they are inverted.
The select() call in w_recv_timeout is written for w_send_timeout.
And viceversa.
Modify the code such that in w_recv_timeout you should have:
ret = select(s+1, &fdset, NULL,NULL, &timeout_t);
And in w_send_timeout:
ret = select(s+1, NULL, &fdset, NULL, &timeout_t);
Now, this is obviously a fatal bug. But the code was working!
How is it possible that the two calls were inverted? And when?!?!?
Bo
By
efphe
_______________________________________________
Netsukuku mailing list
[email protected]
http://lists.dyne.org/mailman/listinfo/netsukuku