Vanilla Clients Maling Clients Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

autologin bug in COW/N:1999



Raven posted to r.g.n. a bug in COW... also exists in Netrek:1999.  I was
able to pinpoint the problem down to this part of code in getname() of
getname.c:


-----
      if (!autolog)
        {
#ifndef WIN32
          timeout.tv_sec = 1;
          timeout.tv_usec = 0;
#else
          /* Since we don't have a socket to check on Win32
             for windowing system events, we set the timeout to zero and
             effectively poll. Yes, I could do the correct thing
             and call WaitForMultipleObjects() etc. but I don't feel like it
*/
          timeout.tv_sec = 0;
          timeout.tv_usec = 100000;
#endif
          FD_ZERO(&readfds);
          FD_SET(sock, &readfds);
          if (udpSock >= 0)
            FD_SET(udpSock, &readfds);
#ifndef WIN32
          FD_SET(W_Socket(), &readfds);
#endif
          if (select(32, &readfds, 0, 0, &timeout) < 0)
            {
              perror("select");
              continue;
            }

          if (FD_ISSET(sock, &readfds)
              || (udpSock >= 0 && FD_ISSET(udpSock, &readfds)))
            readFromServer(&readfds);

#ifndef WIN32
          if (FD_ISSET(W_Socket(), &readfds))
#else
          if (W_EventsPending())
#endif
            handleWEvents(defname);
        }
      else
        {
          readFromServer(&readfds);
        }
----

 The code dies on the readFromServer() line there...

 I believe the problem is that readfds does not get initialized, and then
accessed.

 I believe rewriting this as:

----
		  {
			  handleWEvents(defname);
		  }
		else
	          {
	          readFromServer(&readfds);
		    }
	  }
----

 Thus putting a bracket infront of the handleWEvents() call, and then a
closer bracket after this 'if' statement, to end the (!autolog) test.

Can someone verify that looks right?  It's 12:30 am, time for me to go to
bed, and I quickly ran this through debug and well it "looks ok to me" right
now. :)

 It also appears to work in my quick test.

Steve