CVS: rdesktop proto.h, 1.98, 1.99 rdesktop.c, 1.152, 1.153 xwin.c, 1.215, 1.216

Peter Åstrand <[email protected]> Fri, 27 Oct 2006 05:59:40 -0700
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv31555

Modified Files:
	proto.h rdesktop.c xwin.c 
Log Message:
Prevent segfaults in out of memory conditions by checking the pointer returned from XGetImage.

Index: proto.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/proto.h,v
retrieving revision 1.98
retrieving revision 1.99
diff -C2 -d -r1.98 -r1.99
*** proto.h	26 Oct 2006 09:47:17 -0000	1.98
--- proto.h	27 Oct 2006 12:59:38 -0000	1.99
***************
*** 110,113 ****
--- 110,114 ----
  void generate_random(uint8 * random);
  void *xmalloc(int size);
+ void exit_if_null(void *ptr);
  char *xstrdup(const char *s);
  void *xrealloc(void *oldmem, int size);

Index: rdesktop.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdesktop.c,v
retrieving revision 1.152
retrieving revision 1.153
diff -C2 -d -r1.152 -r1.153
*** rdesktop.c	21 Sep 2006 19:00:11 -0000	1.152
--- rdesktop.c	27 Oct 2006 12:59:38 -0000	1.153
***************
*** 1080,1083 ****
--- 1080,1094 ----
  }
  
+ /* Exit on NULL pointer. Use to verify result from XGetImage etc */
+ void
+ exit_if_null(void *ptr)
+ {
+ 	if (ptr == NULL)
+ 	{
+ 		error("unexpected null pointer. Out of memory?\n");
+ 		exit(1);
+ 	}
+ }
+ 
  /* strdup */
  char *

Index: xwin.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/xwin.c,v
retrieving revision 1.215
retrieving revision 1.216
diff -C2 -d -r1.215 -r1.216
*** xwin.c	26 Oct 2006 09:47:17 -0000	1.215
--- xwin.c	27 Oct 2006 12:59:38 -0000	1.216
***************
*** 3193,3196 ****
--- 3193,3197 ----
  	{
  		image = XGetImage(g_display, g_backstore, x, y, cx, cy, AllPlanes, ZPixmap);
+ 		exit_if_null(image);
  	}
  	else
***************
*** 3199,3202 ****
--- 3200,3204 ----
  		XCopyArea(g_display, g_wnd, pix, g_gc, x, y, cx, cy, 0, 0);
  		image = XGetImage(g_display, pix, 0, 0, cx, cy, AllPlanes, ZPixmap);
+ 		exit_if_null(image);
  		XFreePixmap(g_display, pix);
  	}


-------------------------------------------------------------------------
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