/[rdesktop]/sourceforge.net/trunk/rdesktop/rdpdr.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/rdpdr.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 602 by stargo, Sat Feb 7 17:32:21 2004 UTC revision 710 by jsorg71, Tue Jun 15 22:17:08 2004 UTC
# Line 1  Line 1 
1    /* -*- c-basic-offset: 8 -*-
2       rdesktop: A Remote Desktop Protocol client.
3       Copyright (C) Matthew Chapman 1999-2004
4    
5       This program is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published by
7       the Free Software Foundation; either version 2 of the License, or
8       (at your option) any later version.
9    
10       This program is distributed in the hope that it will be useful,
11       but WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13       GNU General Public License for more details.
14    
15       You should have received a copy of the GNU General Public License
16       along with this program; if not, write to the Free Software
17       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18    */
19    
20    /*
21      Here are some resources, for your IRP hacking pleasure:
22    
23      http://cvs.sourceforge.net/viewcvs.py/mingw/w32api/include/ddk/winddk.h?view=markup
24    
25      http://win32.mvps.org/ntfs/streams.cpp
26    
27      http://www.acc.umu.se/~bosse/ntifs.h
28    
29      http://undocumented.ntinternals.net/UserMode/Undocumented%20Functions/NT%20Objects/File/
30    
31      http://us1.samba.org/samba/ftp/specs/smb-nt01.txt
32    
33      http://www.osronline.com/
34    */
35    
36  #include <unistd.h>  #include <unistd.h>
37  #include <sys/types.h>  #include <sys/types.h>
38    #include <sys/time.h>
39    #include <dirent.h>             /* opendir, closedir, readdir */
40  #include <time.h>  #include <time.h>
41    #include <errno.h>
42  #include "rdesktop.h"  #include "rdesktop.h"
43    
 #define IRP_MJ_CREATE           0x00  
 #define IRP_MJ_CLOSE            0x02  
 #define IRP_MJ_READ             0x03  
 #define IRP_MJ_WRITE            0x04  
 #define IRP_MJ_DEVICE_CONTROL   0x0e  
   
44  #define IRP_MJ_CREATE                   0x00  #define IRP_MJ_CREATE                   0x00
45  #define IRP_MJ_CLOSE                    0x02  #define IRP_MJ_CLOSE                    0x02
46  #define IRP_MJ_READ                     0x03  #define IRP_MJ_READ                     0x03
# Line 18  Line 50 
50  #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a  #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
51  #define IRP_MJ_DIRECTORY_CONTROL        0x0c  #define IRP_MJ_DIRECTORY_CONTROL        0x0c
52  #define IRP_MJ_DEVICE_CONTROL           0x0e  #define IRP_MJ_DEVICE_CONTROL           0x0e
53    #define IRP_MJ_LOCK_CONTROL             0x11
54    
55  #define IRP_MN_QUERY_DIRECTORY          0x01  #define IRP_MN_QUERY_DIRECTORY          0x01
56  #define IRP_MN_NOTIFY_CHANGE_DIRECTORY  0x02  #define IRP_MN_NOTIFY_CHANGE_DIRECTORY  0x02
57    
58  extern char hostname[16];  extern char g_hostname[16];
59  extern DEVICE_FNS serial_fns;  extern DEVICE_FNS serial_fns;
60  extern DEVICE_FNS printer_fns;  extern DEVICE_FNS printer_fns;
61  extern DEVICE_FNS parallel_fns;  extern DEVICE_FNS parallel_fns;
62  extern DEVICE_FNS disk_fns;  extern DEVICE_FNS disk_fns;
63    extern FILEINFO g_fileinfo[];
64    
65  static VCHANNEL *rdpdr_channel;  static VCHANNEL *rdpdr_channel;
66    
# Line 36  uint32 g_num_devices; Line 70  uint32 g_num_devices;
70    
71  /* Table with information about rdpdr devices */  /* Table with information about rdpdr devices */
72  RDPDR_DEVICE g_rdpdr_device[RDPDR_MAX_DEVICES];  RDPDR_DEVICE g_rdpdr_device[RDPDR_MAX_DEVICES];
73    char *g_rdpdr_clientname = NULL;
74    
75  /* Used to store incoming io request, until they are ready to be completed */  /* Used to store incoming io request, until they are ready to be completed */
76  /* using a linked list ensures that they are processed in the right order, */  /* using a linked list ensures that they are processed in the right order, */
# Line 78  convert_to_unix_filename(char *filename) Line 113  convert_to_unix_filename(char *filename)
113          }          }
114  }  }
115    
116    static BOOL
117    rdpdr_handle_ok(int device, int handle)
118    {
119            switch (g_rdpdr_device[device].device_type)
120            {
121                    case DEVICE_TYPE_PARALLEL:
122                    case DEVICE_TYPE_SERIAL:
123                    case DEVICE_TYPE_PRINTER:
124                    case DEVICE_TYPE_SCARD:
125                            if (g_rdpdr_device[device].handle != handle)
126                                    return False;
127                            break;
128                    case DEVICE_TYPE_DISK:
129                            if (g_fileinfo[handle].device_id != device)
130                                    return False;
131                            break;
132            }
133            return True;
134    }
135    
136  /* Add a new io request to the table containing pending io requests so it won't block rdesktop */  /* Add a new io request to the table containing pending io requests so it won't block rdesktop */
137  BOOL  static BOOL
138  add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length,  add_async_iorequest(uint32 device, uint32 file, uint32 id, uint32 major, uint32 length,
139                      DEVICE_FNS * fns, long total_timeout, long interval_timeout, uint8 * buffer)                      DEVICE_FNS * fns, uint32 total_timeout, uint32 interval_timeout, uint8 * buffer,
140                        uint32 offset)
141  {  {
142          struct async_iorequest *iorq;          struct async_iorequest *iorq;
143    
144          if (g_iorequest == NULL)          if (g_iorequest == NULL)
145          {          {
146                  g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));                  g_iorequest = (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
147                    if (!g_iorequest)
148                            return False;
149                  g_iorequest->fd = 0;                  g_iorequest->fd = 0;
150                  g_iorequest->next = NULL;                  g_iorequest->next = NULL;
151          }          }
# Line 101  add_async_iorequest(uint32 device, uint3 Line 159  add_async_iorequest(uint32 device, uint3
159                  {                  {
160                          iorq->next =                          iorq->next =
161                                  (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));                                  (struct async_iorequest *) xmalloc(sizeof(struct async_iorequest));
162                            if (!iorq->next)
163                                    return False;
164                          iorq->next->fd = 0;                          iorq->next->fd = 0;
165                          iorq->next->next = NULL;                          iorq->next->next = NULL;
166                  }                  }
# Line 116  add_async_iorequest(uint32 device, uint3 Line 176  add_async_iorequest(uint32 device, uint3
176          iorq->timeout = total_timeout;          iorq->timeout = total_timeout;
177          iorq->itv_timeout = interval_timeout;          iorq->itv_timeout = interval_timeout;
178          iorq->buffer = buffer;          iorq->buffer = buffer;
179            iorq->offset = offset;
180          return True;          return True;
181  }  }
182    
183  void  static void
184  rdpdr_send_connect(void)  rdpdr_send_connect(void)
185  {  {
186          uint8 magic[4] = "rDCC";          uint8 magic[4] = "rDCC";
# Line 135  rdpdr_send_connect(void) Line 196  rdpdr_send_connect(void)
196  }  }
197    
198    
199  void  static void
200  rdpdr_send_name(void)  rdpdr_send_name(void)
201  {  {
202          uint8 magic[4] = "rDNC";          uint8 magic[4] = "rDNC";
         uint32 hostlen = (strlen(hostname) + 1) * 2;  
203          STREAM s;          STREAM s;
204            uint32 hostlen;
205    
206            if (NULL == g_rdpdr_clientname)
207            {
208                    g_rdpdr_clientname = g_hostname;
209            }
210            hostlen = (strlen(g_rdpdr_clientname) + 1) * 2;
211    
212          s = channel_init(rdpdr_channel, 16 + hostlen);          s = channel_init(rdpdr_channel, 16 + hostlen);
213          out_uint8a(s, magic, 4);          out_uint8a(s, magic, 4);
# Line 148  rdpdr_send_name(void) Line 215  rdpdr_send_name(void)
215          out_uint16_le(s, 0x72);          out_uint16_le(s, 0x72);
216          out_uint32(s, 0);          out_uint32(s, 0);
217          out_uint32_le(s, hostlen);          out_uint32_le(s, hostlen);
218          rdp_out_unistr(s, hostname, hostlen - 2);          rdp_out_unistr(s, g_rdpdr_clientname, hostlen - 2);
219          s_mark_end(s);          s_mark_end(s);
220          channel_send(s, rdpdr_channel);          channel_send(s, rdpdr_channel);
221  }  }
222    
223  /* Returns the size of the payload of the announce packet */  /* Returns the size of the payload of the announce packet */
224  int  static int
225  announcedata_size()  announcedata_size()
226  {  {
227          int size, i;          int size, i;
# Line 181  announcedata_size() Line 248  announcedata_size()
248          return size;          return size;
249  }  }
250    
251  void  static void
252  rdpdr_send_available(void)  rdpdr_send_available(void)
253  {  {
254    
# Line 239  rdpdr_send_available(void) Line 306  rdpdr_send_available(void)
306          channel_send(s, rdpdr_channel);          channel_send(s, rdpdr_channel);
307  }  }
308    
309  void  static void
310  rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,  rdpdr_send_completion(uint32 device, uint32 id, uint32 status, uint32 result, uint8 * buffer,
311                        uint32 length)                        uint32 length)
312  {  {
# Line 384  rdpdr_process_irp(STREAM s) Line 451  rdpdr_process_irp(STREAM s)
451  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
452                          DEBUG(("RDPDR IRP Read (length: %d, offset: %d)\n", length, offset));                          DEBUG(("RDPDR IRP Read (length: %d, offset: %d)\n", length, offset));
453  #endif  #endif
454                            if (!rdpdr_handle_ok(device, file))
455                            {
456                                    status = STATUS_INVALID_HANDLE;
457                                    break;
458                            }
459    
460                          if (rw_blocking)        // Complete read immediately                          if (rw_blocking)        // Complete read immediately
461                          {                          {
462                                  buffer = (uint8 *) xrealloc((void *) buffer, length);                                  buffer = (uint8 *) xrealloc((void *) buffer, length);
463                                    if (!buffer)
464                                    {
465                                            status = STATUS_CANCELLED;
466                                            break;
467                                    }
468                                  status = fns->read(file, buffer, length, offset, &result);                                  status = fns->read(file, buffer, length, offset, &result);
469                                  buffer_len = result;                                  buffer_len = result;
470                                  break;                                  break;
# Line 394  rdpdr_process_irp(STREAM s) Line 472  rdpdr_process_irp(STREAM s)
472    
473                          // Add request to table                          // Add request to table
474                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
475                            if (!pst_buf)
476                            {
477                                    status = STATUS_CANCELLED;
478                                    break;
479                            }
480                          serial_get_timeout(file, length, &total_timeout, &interval_timeout);                          serial_get_timeout(file, length, &total_timeout, &interval_timeout);
481                          if (add_async_iorequest                          if (add_async_iorequest
482                              (device, file, id, major, length, fns, total_timeout, interval_timeout,                              (device, file, id, major, length, fns, total_timeout, interval_timeout,
483                               pst_buf))                               pst_buf, offset))
484                          {                          {
485                                  status = STATUS_PENDING;                                  status = STATUS_PENDING;
486                                  break;                                  break;
# Line 421  rdpdr_process_irp(STREAM s) Line 504  rdpdr_process_irp(STREAM s)
504  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
505                          DEBUG(("RDPDR IRP Write (length: %d)\n", result));                          DEBUG(("RDPDR IRP Write (length: %d)\n", result));
506  #endif  #endif
507                            if (!rdpdr_handle_ok(device, file))
508                            {
509                                    status = STATUS_INVALID_HANDLE;
510                                    break;
511                            }
512    
513                          if (rw_blocking)        // Complete immediately                          if (rw_blocking)        // Complete immediately
514                          {                          {
515                                  status = fns->write(file, s->p, length, offset, &result);                                  status = fns->write(file, s->p, length, offset, &result);
# Line 429  rdpdr_process_irp(STREAM s) Line 518  rdpdr_process_irp(STREAM s)
518    
519                          // Add to table                          // Add to table
520                          pst_buf = (uint8 *) xmalloc(length);                          pst_buf = (uint8 *) xmalloc(length);
521                            if (!pst_buf)
522                            {
523                                    status = STATUS_CANCELLED;
524                                    break;
525                            }
526    
527                          in_uint8a(s, pst_buf, length);                          in_uint8a(s, pst_buf, length);
528    
529                          if (add_async_iorequest                          if (add_async_iorequest
530                              (device, file, id, major, length, fns, 0, 0, pst_buf))                              (device, file, id, major, length, fns, 0, 0, pst_buf, offset))
531                          {                          {
532                                  status = STATUS_PENDING;                                  status = STATUS_PENDING;
533                                  break;                                  break;
# Line 552  rdpdr_process_irp(STREAM s) Line 647  rdpdr_process_irp(STREAM s)
647                          in_uint8s(s, 0x14);                          in_uint8s(s, 0x14);
648    
649                          buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14);                          buffer = (uint8 *) xrealloc((void *) buffer, bytes_out + 0x14);
650                            if (!buffer)
651                            {
652                                    status = STATUS_CANCELLED;
653                                    break;
654                            }
655    
656                          out.data = out.p = buffer;                          out.data = out.p = buffer;
657                          out.size = sizeof(buffer);                          out.size = sizeof(buffer);
658                          status = fns->device_control(file, request, s, &out);                          status = fns->device_control(file, request, s, &out);
659                          result = buffer_len = out.p - out.data;                          result = buffer_len = out.p - out.data;
660                          break;                          break;
661    
662    
663                    case IRP_MJ_LOCK_CONTROL:
664    
665                            if (g_rdpdr_device[device].device_type != DEVICE_TYPE_DISK)
666                            {
667                                    status = STATUS_INVALID_HANDLE;
668                                    break;
669                            }
670    
671                            in_uint32_le(s, info_level);
672    
673                            out.data = out.p = buffer;
674                            out.size = sizeof(buffer);
675                            /* FIXME: Perhaps consider actually *do*
676                               something here :-) */
677                            status = STATUS_SUCCESS;
678                            result = buffer_len = out.p - out.data;
679                            break;
680    
681                  default:                  default:
682                          unimpl("IRP major=0x%x minor=0x%x\n", major, minor);                          unimpl("IRP major=0x%x minor=0x%x\n", major, minor);
683                          break;                          break;
# Line 567  rdpdr_process_irp(STREAM s) Line 687  rdpdr_process_irp(STREAM s)
687          {          {
688                  rdpdr_send_completion(device, id, status, result, buffer, buffer_len);                  rdpdr_send_completion(device, id, status, result, buffer, buffer_len);
689          }          }
690          xfree(buffer);          if (buffer)
691                    xfree(buffer);
692            buffer = NULL;
693  }  }
694    
695  void  static void
696  rdpdr_send_clientcapabilty(void)  rdpdr_send_clientcapabilty(void)
697  {  {
698          uint8 magic[4] = "rDPC";          uint8 magic[4] = "rDPC";
# Line 687  rdpdr_init() Line 808  rdpdr_init()
808  void  void
809  rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout)  rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, BOOL * timeout)
810  {  {
811          long select_timeout = 0;        // Timeout value to be used for select() (in millisecons).          uint32 select_timeout = 0;      // Timeout value to be used for select() (in millisecons).
812          struct async_iorequest *iorq;          struct async_iorequest *iorq;
813            char c;
814    
815          iorq = g_iorequest;          iorq = g_iorequest;
816          while (iorq != NULL)          while (iorq != NULL)
# Line 698  rdpdr_add_fds(int *n, fd_set * rfds, fd_ Line 820  rdpdr_add_fds(int *n, fd_set * rfds, fd_
820                          switch (iorq->major)                          switch (iorq->major)
821                          {                          {
822                                  case IRP_MJ_READ:                                  case IRP_MJ_READ:
823                                            /* Is this FD valid? FDs will
824                                               be invalid when
825                                               reconnecting. FIXME: Real
826                                               support for reconnects. */
827    
828                                            if ((read(iorq->fd, &c, 0) != 0) && (errno == EBADF))
829                                                    break;
830    
831                                          FD_SET(iorq->fd, rfds);                                          FD_SET(iorq->fd, rfds);
832                                            *n = MAX(*n, iorq->fd);
833    
834                                          // Check if io request timeout is smaller than current (but not 0).                                          // Check if io request timeout is smaller than current (but not 0).
835                                          if (iorq->timeout                                          if (iorq->timeout
# Line 713  rdpdr_add_fds(int *n, fd_set * rfds, fd_ Line 843  rdpdr_add_fds(int *n, fd_set * rfds, fd_
843                                                  tv->tv_usec = (select_timeout % 1000) * 1000;                                                  tv->tv_usec = (select_timeout % 1000) * 1000;
844                                                  *timeout = True;                                                  *timeout = True;
845                                          }                                          }
846    
847                                          break;                                          break;
848    
849                                  case IRP_MJ_WRITE:                                  case IRP_MJ_WRITE:
850                                            /* FD still valid? See above. */
851                                            if ((write(iorq->fd, &c, 0) != 0) && (errno == EBADF))
852                                                    break;
853    
854                                          FD_SET(iorq->fd, wfds);                                          FD_SET(iorq->fd, wfds);
855                                            *n = MAX(*n, iorq->fd);
856                                          break;                                          break;
857    
858                          }                          }
859                          *n = MAX(*n, iorq->fd);  
860                  }                  }
861    
862                  iorq = iorq->next;                  iorq = iorq->next;
863          }          }
864  }  }
865    
866    struct async_iorequest *
867    rdpdr_remove_iorequest(struct async_iorequest *prev, struct async_iorequest *iorq)
868    {
869            if (!iorq)
870                    return NULL;
871    
872            if (iorq->buffer)
873                    xfree(iorq->buffer);
874            if (prev)
875            {
876                    prev->next = iorq->next;
877                    xfree(iorq);
878                    iorq = prev->next;
879            }
880            else
881            {
882                    // Even if NULL
883                    g_iorequest = iorq->next;
884                    xfree(iorq);
885                    iorq = NULL;
886            }
887            return iorq;
888    }
889    
890  /* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */  /* Check if select() returned with one of the rdpdr file descriptors, and complete io if it did */
891  void  void
# Line 766  rdpdr_check_fds(fd_set * rfds, fd_set * Line 925  rdpdr_check_fds(fd_set * rfds, fd_set *
925                                                  /* never read larger chunks than 8k - chances are that it will block */                                                  /* never read larger chunks than 8k - chances are that it will block */
926                                                  status = fns->read(iorq->fd,                                                  status = fns->read(iorq->fd,
927                                                                     iorq->buffer + iorq->partial_len,                                                                     iorq->buffer + iorq->partial_len,
928                                                                     req_size, 0, &result);                                                                     req_size, iorq->offset, &result);
                                                 iorq->partial_len += result;  
929    
930                                                    if (result > 0)
931                                                    {
932                                                            iorq->partial_len += result;
933                                                            iorq->offset += result;
934                                                    }
935  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
936                                                  DEBUG(("RDPDR: %d bytes of data read\n", result));                                                  DEBUG(("RDPDR: %d bytes of data read\n", result));
937  #endif  #endif
# Line 780  rdpdr_check_fds(fd_set * rfds, fd_set * Line 943  rdpdr_check_fds(fd_set * rfds, fd_set *
943  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
944                                                          DEBUG(("RDPDR: AIO total %u bytes read of %u\n", iorq->partial_len, iorq->length));                                                          DEBUG(("RDPDR: AIO total %u bytes read of %u\n", iorq->partial_len, iorq->length));
945  #endif  #endif
                                                         /* send the data */  
                                                         status = STATUS_SUCCESS;  
946                                                          rdpdr_send_completion(iorq->device,                                                          rdpdr_send_completion(iorq->device,
947                                                                                iorq->id, status,                                                                                iorq->id, status,
948                                                                                iorq->partial_len,                                                                                iorq->partial_len,
949                                                                                iorq->buffer,                                                                                iorq->buffer,
950                                                                                iorq->partial_len);                                                                                iorq->partial_len);
951                                                          xfree(iorq->buffer);                                                          iorq = rdpdr_remove_iorequest(prev, iorq);
                                                         iorq->fd = 0;  
                                                         if (prev != NULL)  
                                                         {  
                                                                 prev->next = iorq->next;  
                                                                 xfree(iorq);  
                                                         }  
                                                         else  
                                                         {  
                                                                 // Even if NULL  
                                                                 g_iorequest = iorq->next;  
                                                                 xfree(iorq);  
                                                         }  
952                                                  }                                                  }
953                                          }                                          }
954                                          break;                                          break;
# Line 817  rdpdr_check_fds(fd_set * rfds, fd_set * Line 966  rdpdr_check_fds(fd_set * rfds, fd_set *
966                                                  /* never write larger chunks than 8k - chances are that it will block */                                                  /* never write larger chunks than 8k - chances are that it will block */
967                                                  status = fns->write(iorq->fd,                                                  status = fns->write(iorq->fd,
968                                                                      iorq->buffer +                                                                      iorq->buffer +
969                                                                      iorq->partial_len, req_size, 0,                                                                      iorq->partial_len, req_size,
970                                                                      &result);                                                                      iorq->offset, &result);
971                                                  iorq->partial_len += result;  
972                                                    if (result > 0)
973                                                    {
974                                                            iorq->partial_len += result;
975                                                            iorq->offset += result;
976                                                    }
977    
978  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
979                                                  DEBUG(("RDPDR: %d bytes of data written\n",                                                  DEBUG(("RDPDR: %d bytes of data written\n",
980                                                         result));                                                         result));
# Line 832  rdpdr_check_fds(fd_set * rfds, fd_set * Line 987  rdpdr_check_fds(fd_set * rfds, fd_set *
987  #if WITH_DEBUG_RDP5  #if WITH_DEBUG_RDP5
988                                                          DEBUG(("RDPDR: AIO total %u bytes written of %u\n", iorq->partial_len, iorq->length));                                                          DEBUG(("RDPDR: AIO total %u bytes written of %u\n", iorq->partial_len, iorq->length));
989  #endif  #endif
                                                         /* send a status success */  
                                                         status = STATUS_SUCCESS;  
990                                                          rdpdr_send_completion(iorq->device,                                                          rdpdr_send_completion(iorq->device,
991                                                                                iorq->id, status,                                                                                iorq->id, status,
992                                                                                iorq->partial_len, (uint8*)"",                                                                                iorq->partial_len,
993                                                                                1);                                                                                (uint8 *) "", 1);
994    
995                                                          xfree(iorq->buffer);                                                          iorq = rdpdr_remove_iorequest(prev, iorq);
                                                         iorq->fd = 0;  
                                                         if (prev != NULL)  
                                                         {  
                                                                 prev->next = iorq->next;  
                                                                 xfree(iorq);  
                                                         }  
                                                         else  
                                                         {  
                                                                 // Even if NULL  
                                                                 g_iorequest = iorq->next;  
                                                                 xfree(iorq);  
                                                         }  
996                                                  }                                                  }
997                                          }                                          }
998                                          break;                                          break;
# Line 859  rdpdr_check_fds(fd_set * rfds, fd_set * Line 1000  rdpdr_check_fds(fd_set * rfds, fd_set *
1000    
1001                  }                  }
1002                  prev = iorq;                  prev = iorq;
1003                  iorq = iorq->next;                  if (iorq)
1004                            iorq = iorq->next;
1005          }          }
1006    
1007  }  }
# Line 881  rdpdr_abort_io(uint32 fd, uint32 major, Line 1023  rdpdr_abort_io(uint32 fd, uint32 major,
1023                  if ((iorq->fd == fd) && (major == 0 || iorq->major == major))                  if ((iorq->fd == fd) && (major == 0 || iorq->major == major))
1024                  {                  {
1025                          result = 0;                          result = 0;
1026                          rdpdr_send_completion(iorq->device, iorq->id, status, result, (uint8*)"", 1);                          rdpdr_send_completion(iorq->device, iorq->id, status, result, (uint8 *) "",
1027                          xfree(iorq->buffer);                                                1);
1028                          iorq->fd = 0;  
1029                          if (prev != NULL)                          iorq = rdpdr_remove_iorequest(prev, iorq);
                         {  
                                 prev->next = iorq->next;  
                                 xfree(iorq);  
                         }  
                         else  
                         {  
                                 // Even if NULL  
                                 g_iorequest = iorq->next;  
                                 xfree(iorq);  
                         }  
1030                          return True;                          return True;
1031                  }                  }
1032    

Legend:
Removed from v.602  
changed lines
  Added in v.710

  ViewVC Help
Powered by ViewVC 1.1.26