[PATCH] xfbbd: Fix issue with xfbbd and AX25 radio connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Patch versus version xfbbd version r11

Same patch file, Except I changed the email subject.



1. SOCK_MAXCHAN (drv_sock.c) now set to (MAXVOIES)  This was set to 50, which was less than MAXVOIES, and the code was
accessing data off the end of this table.  This was causing strange problems.  After I made this change the gateway
function started working again.  If anyone was having trouble with xfbbd and RF radio connections, this change may
possibly fix their problem.
2.  Several minor changes designed to eliminate "Bad file descriptor" error messages.  These occurred at the time
of housekeeping due to a minor bug.  The messages actually turned out to be harmless, as far as I can tell.
3.  Only use the signal handler for signals that have functionality in the code.  This is a simplification
to prevent bugs.  Other signals are set to SIG_IGN.


diff -ruN fbbsrc.704r11/src/drv_sock.c fbbsrc.704r11cathryn/src/drv_sock.c
--- fbbsrc.704r11/src/drv_sock.c	2010-06-22 13:03:01.000000000 -0700
+++ fbbsrc.704r11cathryn/src/drv_sock.c	2010-11-13 22:43:56.284120401 -0800
@@ -74,7 +74,8 @@
 #define RETR_EVENT 3
 #define BUSY_EVENT 4
 
-#define SOCK_MAXCAN 50
+#define SOCK_MAXCAN  (MAXVOIES) /* was 50 -- this was causing bad problems. 
+			This table was being accessed beyond the array */
 
 #define	CAN_AX25	0
 #define	CAN_NETROM	1
@@ -104,7 +105,7 @@
 }
 scan_t;
 
-scan_t scan[SOCK_MAXCAN];
+scan_t scan[SOCK_MAXCAN] = {{0}};  /* I think this is necessary (Though not 100% sure.  */
 
 static int last_can = 1;
 static int msocket = -1;
@@ -692,8 +693,11 @@
 
 static int stop_cnx (int port)
 {
-	close(p_port[port].fd);
-	p_port[port].fd = 0;
+	if (p_port[port].fd) /* Prevent closing of 0 */
+	{
+		close(p_port[port].fd);
+		p_port[port].fd = 0;
+	}
 	return 1;
 }
 
diff -ruN fbbsrc.704r11/src/drv_tcp.c fbbsrc.704r11cathryn/src/drv_tcp.c
--- fbbsrc.704r11/src/drv_tcp.c	2009-11-27 08:50:44.000000000 -0800
+++ fbbsrc.704r11cathryn/src/drv_tcp.c	2010-11-13 16:55:53.363119445 -0800
@@ -950,8 +950,11 @@
 
 static int stop_cnx (int port)
 {
-	close(p_port[port].fd);
-	p_port[port].fd = 0;
+	if (p_port[port].fd) /* Prevent closing of 0 */
+	{
+		close(p_port[port].fd);
+		p_port[port].fd = 0;
+	}
 	return 1;
 }
 
@@ -1439,7 +1442,7 @@
 	fd_set tcp_excep;
 	struct timeval to;
 
-	if (can->sock == -1)
+	if (can->sock <= 0) /* Was -1.  Sock=0 during housekeeping.  Cause of select errors */
 		return (0);
 
 	if ((can->timeout) && (can->timeout < time (NULL)))
diff -ruN fbbsrc.704r11/src/xfbbd.c fbbsrc.704r11cathryn/src/xfbbd.c
--- fbbsrc.704r11/src/xfbbd.c	2009-11-27 08:50:44.000000000 -0800
+++ fbbsrc.704r11cathryn/src/xfbbd.c	2010-11-13 17:10:40.879123108 -0800
@@ -195,7 +195,10 @@
 	{
 		if (i == SIGBUS || i == SIGSEGV || i == SIGALRM)
 			continue;
-		signal (i, sig_fct);
+		else if (i == SIGHUP  || i == SIGTERM || i == SIGBUS || i == SIGSEGV)
+			signal (i, sig_fct); /* Use sig_fct only for signals that do something */
+		else 	
+			signal (i, SIG_IGN); /* Otherwise ignore */
 	}
 
 	for (ng = 1; ng < ac; ng++)

[Linux Newbie]     [Kernel Newbies]     [Memory]     [Git]     [Security]     [Netfilter]     [Linux Admin]     [Bugtraq]     [Photo]     [Yosemite Photos]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [ARM Linux Kernel]     [Linux Networking]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linux Resources]

Add to Google Powered by Linux