CVS: rdesktop proto.h, 1.100, 1.101 rdpdr.c, 1.45, 1.46 scard.c, 1.12, 1.13 secure.c, 1.61, 1.62

Michael Gernoth <[email protected]> Fri, 03 Nov 2006 11:56:45 -0800
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20025

Modified Files:
	proto.h rdpdr.c scard.c secure.c 
Log Message:
make sure to lock the datapath of rdpdr_send_completion to prevent
simultaneous access to shared variables in multiple threads


Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.100
retrieving revision 1.101
diff -C2 -d -r1.100 -r1.101
*** proto.h	1 Nov 2006 20:52:00 -0000	1.100
--- proto.h	3 Nov 2006 19:56:42 -0000	1.101
***************
*** 310,313 ****
--- 310,315 ----
  void scard_tcp_lock(void);
  void scard_tcp_unlock(void);
+ void scard_sec_lock(void);
+ void scard_sec_unlock(void);
  STREAM scard_tcp_init(void);
  void scard_tcp_connect(void);

Index: rdpdr.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpdr.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -C2 -d -r1.45 -r1.46
*** rdpdr.c	2 Nov 2006 20:48:28 -0000	1.45
--- rdpdr.c	3 Nov 2006 19:56:42 -0000	1.46
***************
*** 67,71 ****
--- 67,75 ----
  extern BOOL g_notify_stamp;
  
+ #ifdef WITH_SCARD
+ VCHANNEL *rdpdr_channel;
+ #else
  static VCHANNEL *rdpdr_channel;
+ #endif
  
  /* If select() times out, the request for the device with handle g_min_timeout_fd is aborted */

Index: scard.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/scard.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** scard.c	3 Nov 2006 18:57:09 -0000	1.12
--- scard.c	3 Nov 2006 19:56:42 -0000	1.13
***************
*** 46,49 ****
--- 46,50 ----
  static int cur_stream_id = 0;
  static pthread_mutex_t *tcp_sendcontrol_mutex = NULL;
+ static pthread_mutex_t *sec_channels_mutex = NULL;
  
  static uint32 curDevice = 0, curId = 0, curBytesOut = 0;
***************
*** 55,59 ****
  static pthread_mutex_t queueEmpty;
  static pthread_mutex_t hcardAccess;
- static pthread_mutex_t sendControl;
  
  static PMEM_HANDLE threadListHandle = NULL;
--- 56,59 ----
***************
*** 153,162 ****
  	}
  
- 	if (0 != pthread_mutex_init(&sendControl, NULL))
- 	{
- 		error("[SMART CARD: Can't initialize send control mutex]\n");
- 		return 0;
- 	}
- 
  	if (0 !=
  	    pthread_create(&queueHandler, NULL, (void *(*)(void *)) queue_handler_function, NULL))
--- 153,156 ----
***************
*** 2498,2504 ****
  	scard_device_control(data->handle, data->request, data->in, data->out);
  	buffer_len = (size_t) data->out->p - (size_t) data->out->data;
- 	pthread_mutex_lock(&sendControl);
  	rdpdr_send_completion(data->device, data->id, 0, buffer_len, data->out->data, buffer_len);
- 	pthread_mutex_unlock(&sendControl);
  	SC_destroyThreadData(data);
  }
--- 2492,2496 ----
***************
*** 2646,2649 ****
--- 2638,2659 ----
  }
  
+ void
+ scard_sec_lock(void)
+ {
+ 	if (!sec_channels_mutex)
+ 	{
+ 		sec_channels_mutex = (pthread_mutex_t *) xmalloc(sizeof(pthread_mutex_t));
+ 		pthread_mutex_init(sec_channels_mutex, NULL);
+ 	}
+ 
+ 	pthread_mutex_lock(sec_channels_mutex);
+ }
+ 
+ void
+ scard_sec_unlock(void)
+ {
+ 	pthread_mutex_unlock(sec_channels_mutex);
+ }
+ 
  STREAM
  scard_tcp_init(void)

Index: secure.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/secure.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** secure.c	1 Nov 2006 22:12:27 -0000	1.61
--- secure.c	3 Nov 2006 19:56:42 -0000	1.62
***************
*** 363,366 ****
--- 363,370 ----
  	int datalen;
  
+ #ifdef WITH_SCARD
+ 	scard_sec_lock();
+ #endif
+ 
  	s_pop_layer(s, sec_hdr);
  	if (!g_licence_issued || (flags & SEC_ENCRYPT))
***************
*** 382,385 ****
--- 386,393 ----
  
  	mcs_send_to_channel(s, channel);
+ 
+ #ifdef WITH_SCARD
+ 	scard_sec_unlock();
+ #endif
  }
  


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642