Rshd functions correctly until the number of the stderr port is superior than 0.
In the rshd.cpp file, in the rresvport function, in the loop for, before binding, the number of the port *alport must be in the 512-1023 range.
So to correct this problem, you have to test the number of the port *alport before binding.
int
rresvport (int* alport)
{
...
for(;i;i--,(*alport)--)
{
if(*alport==IPPORT_RESERVED/2) // IPPORT_RESERVED == 1024
*alport=IPPORT_RESERVED; // wrap up and start all over
sin.sin_port=htons((u_short)*alport);
if(bind(s, (struct sockaddr*)&sin, sizeof(sin))==0)
{
lastport=*alport;
rshunlock();
return s;
}
if(WSAGetLastError()!=WSAEADDRINUSE)
break;
}
...
}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Rshd functions correctly until the number of the stderr port is superior than 0.
In the rshd.cpp file, in the rresvport function, in the loop for, before binding, the number of the port *alport must be in the 512-1023 range.
So to correct this problem, you have to test the number of the port *alport before binding.
int
rresvport (int* alport)
{
...
for(;i;i--,(*alport)--)
{
if(*alport==IPPORT_RESERVED/2) // IPPORT_RESERVED == 1024
*alport=IPPORT_RESERVED; // wrap up and start all over
sin.sin_port=htons((u_short)*alport);
if(bind(s, (struct sockaddr*)&sin, sizeof(sin))==0)
{
lastport=*alport;
rshunlock();
return s;
}
if(WSAGetLastError()!=WSAEADDRINUSE)
break;
}
...
}