$OpenBSD: patch-rdpdr_c,v 1.2 2014/11/17 15:09:16 benoit Exp $

Fix crash when a invalid device is received in rdpdr_process_irp.
patch from upstream
http://sourceforge.net/p/rdesktop/code/1701/

--- rdpdr.c.orig	Thu Sep 11 13:54:46 2014
+++ rdpdr.c	Mon Nov 17 11:50:04 2014
@@ -388,6 +388,15 @@ rdpdr_process_irp(STREAM s)
 		return;
 	}
 
+	if(device >= RDPDR_MAX_DEVICES)
+	{
+		error("%s invalid device 0x%lx file 0x%lx id 0x%lx "
+			"major 0x%lx minor 0x%lx\n", device, file, id,
+			major, minor);
+		if (buffer)
+			xfree(buffer);
+		return;
+	}
 	switch (g_rdpdr_device[device].device_type)
 	{
 		case DEVICE_TYPE_SERIAL:
