[freetds] Error in tds_check_socket_write()

Sergey A. Cherukhin rf at ce.cctpu.edu.ru
Fri Sep 23 07:03:15 EDT 2005


Hello freetds,

I have found error in freetds-0.63, which result in segmentation fault
when   tds_check_socket_write()   called  with  negative  socket  file
descriptor. See patch below.
  
*** freetds-0.63-cvs/src/tds/write.c    Thu Jul 29 18:22:42 2004
--- freetds-0.63/src/tds/write.c        Fri Sep 23 14:57:06 2005
***************
*** 277,290 ****
--- 277,293 ----
  tds_check_socket_write(TDSSOCKET * tds)
  {
        int retcode = 0;
        struct timeval selecttimeout;
        time_t start, now;
        fd_set fds;
  
+       if (tds->s < 0) 
+               return -1; /* Fix of SIGSEGV when FD_SET() called with negative fd (S. Cherukhin, 23/09/2005) */
+ 
        /* Jeffs hack *** START OF NEW CODE */
        FD_ZERO(&fds);
  
        if (!tds->timeout) {
                for (;;) {
                        FD_SET(tds->s, &fds);
                        retcode = select(tds->s + 1, NULL, &fds, NULL, NULL);

-- 
Best regards,
 Sergey A. Cherukhin                          mailto:rf at ce.cctpu.edu.ru
 23.09.2005




More information about the FreeTDS mailing list