Re: port limitation to int16

Johannes Wienke <[email protected]> Thu, 08 Aug 2013 16:20:57 +0200
Newsgroups gmane.network.spread.user
Message-ID <[email protected]>
Hi again,

On 08/08/2013 03:41 PM, Johannes Wienke wrote:
[..]
> There is an integer overflow in the
> daemon and this does not only exist in the printing. Actually the socket
> file in /tmp is really called -17536. The client API doesn't seem to
> have this overflow and tries to correctly find a file with name 48000.

Attached is a patch fixing the problems.

Kind regards,
Johannes

_______________________________________________
Spread-users mailing list
[email protected]
http://lists.spread.org/mailman/listinfo/spread-users
high-port-fix.patch (text/x-patch, 4.4 KB)
diff -ru /tmp/spread-src-4.3.0/daemon/configuration.c spread-src-4.3.0/daemon/configuration.c
--- /tmp/spread-src-4.3.0/daemon/configuration.c	2013-03-25 06:01:02.000000000 +0100
+++ spread-src-4.3.0/daemon/configuration.c	2013-08-08 16:15:34.185144256 +0200
@@ -285,7 +285,7 @@
                      (np.ifc[i].port != op.ifc[i].port) ||
                      (np.ifc[i].type != op.ifc[i].type) ) 
                 {
-                        Alarmp( SPLOG_FATAL, CONF_SYS, "Conf_reload_initiate: My interface spec has changed so must exit: old (%d.%d.%d.%d:%d - %d) new (%d.%d.%d.%d:%d - %d)\n", IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip), op.ifc[i].port, op.ifc[i].type, IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip), np.ifc[i].port, np.ifc[i].type );
+                        Alarmp( SPLOG_FATAL, CONF_SYS, "Conf_reload_initiate: My interface spec has changed so must exit: old (%d.%d.%d.%d:%hu - %d) new (%d.%d.%d.%d:%hu - %d)\n", IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip), op.ifc[i].port, op.ifc[i].type, IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip), np.ifc[i].port, np.ifc[i].type );
                 }
         }
         /* Check if only new configuration contains only additions and subtractions of daemons and no changes */
@@ -310,7 +310,7 @@
                                      (np.ifc[i].type != op.ifc[i].type) ) 
                                 {
                                         need_partition = TRUE;
-                                        Alarmp( SPLOG_DEBUG, CONF_SYS, "Conf_reload_initiate: daemon interface spec for %d.%d.%d.%d has changed.: old (%d.%d.%d.%d:%d - %d) new (%d.%d.%d.%d:%d - %d)\n", IP1(np.id), IP2(np.id), IP3(np.id), IP4(np.id), IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip), op.ifc[i].port, op.ifc[i].type, IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip), np.ifc[i].port, np.ifc[i].type );
+                                        Alarmp( SPLOG_DEBUG, CONF_SYS, "Conf_reload_initiate: daemon interface spec for %d.%d.%d.%d has changed.: old (%d.%d.%d.%d:%hu - %d) new (%d.%d.%d.%d:%hu - %d)\n", IP1(np.id), IP2(np.id), IP3(np.id), IP4(np.id), IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip),  IP1(op.ifc[i].ip), op.ifc[i].port, op.ifc[i].type, IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip),  IP1(np.ifc[i].ip), np.ifc[i].port, np.ifc[i].type );
                                 }
                         }
                 } /* else */
@@ -486,7 +486,7 @@
 	}
 
 	Conf_id_to_str( My.id, ip );
-	Alarm( CONF_SYS, "Conf_load_conf_file: My name: %s, id: %s, port: %hd\n",
+	Alarm( CONF_SYS, "Conf_load_conf_file: My name: %s, id: %s, port: %hu\n",
 		My.name, ip, My.port );
 
 	return;
@@ -757,7 +757,7 @@
 	for ( s=0; s < config->num_segments; s++ )
 	{
 		Conf_id_to_str( config->segments[s].bcast_address, ip );
-		Alarm( PRINT, "\t%d\t%-16s  %hd\n",
+		Alarm( PRINT, "\t%d\t%-16s  %hu\n",
 			config->segments[s].num_procs, ip,
 			config->segments[s].port );
 		for( p=0; p < config->segments[s].num_procs; p++)
@@ -784,7 +784,7 @@
 	for ( i=0; i < config->num_total_procs; i++ )
 	{
                 Conf_id_to_str( config->allprocs[i].id, ip );
-                Alarm( PRINT, "\t%s:%d\tID: %-16s NumIF: %d\n",
+                Alarm( PRINT, "\t%s:%hu\tID: %-16s NumIF: %d\n",
                        config->allprocs[i].name, config->allprocs[i].port,
                        ip, config->allprocs[i].num_if);
         }
diff -ru /tmp/spread-src-4.3.0/daemon/configuration.h spread-src-4.3.0/daemon/configuration.h
--- /tmp/spread-src-4.3.0/daemon/configuration.h	2013-03-25 06:01:02.000000000 +0100
+++ spread-src-4.3.0/daemon/configuration.h	2013-08-08 16:07:15.397198306 +0200
@@ -62,7 +62,7 @@
 };
 typedef struct dummy_proc{
 	char	name[MAX_PROC_NAME]; 
-	int16	port;
+	int16u	port;
 	int16	seg_index;
 	int16	index_in_seg;
 	int32u	id;
diff -ru /tmp/spread-src-4.3.0/daemon/y.tab.c spread-src-4.3.0/daemon/y.tab.c
--- /tmp/spread-src-4.3.0/daemon/y.tab.c	2013-06-12 05:55:31.000000000 +0200
+++ spread-src-4.3.0/daemon/y.tab.c	2013-08-08 16:12:04.023059899 +0200
@@ -308,7 +308,7 @@
 static char *segment2str(int seg) {
   static char ipstr[40];
   int id = Config->segments[seg].bcast_address;
-  sprintf(ipstr, "%d.%d.%d.%d:%d",
+  sprintf(ipstr, "%d.%d.%d.%d:%hu",
   	(id & 0xff000000)>>24,
   	(id & 0xff0000)>>16,
   	(id & 0xff00)>>8,
signature.asc (application/pgp-signature, 263 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlIDqUkACgkQBFcR5UV/ccLVhQCfWIuKQd6U6cDDTE1/SMVHv4VG
IaQAnjclLd6dmwtqpAuKLTYM4MmMi0HG
=P8hQ
-----END PGP SIGNATURE-----