[Spread-cvs] cvs commit: spread/daemon configuration.c groups.c network.c session.c simple_user.c sp.c user.c Readme.txt

jonathan at spread.org jonathan at spread.org
Thu Sep 23 19:15:18 EDT 2004


jonathan    04/09/23 19:15:18

  Modified:    daemon   configuration.c groups.c network.c session.c
                        simple_user.c sp.c user.c Readme.txt
  Log:
  Fix bug with SP_Join/Leave not rejecting group names that are too long.
  Reported with fix from David Parker.
  Also cleanup incorrect use of signed int as return value of strlen()
  and some compile warnings with E_queue() usage.
  
  Revision  Changes    Path
  1.9       +11 -11    spread/daemon/configuration.c
  
  Index: configuration.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/configuration.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- configuration.c	5 Mar 2004 00:32:46 -0000	1.8
  +++ configuration.c	23 Sep 2004 23:15:18 -0000	1.9
  @@ -106,9 +106,11 @@
           struct hostent  *host_ptr;
   	char	machine_name[256];
   	char	ip[16];
  -	int	s,i,j;
  +	int	i,j;
  +        unsigned int name_len;
           char    configfile_location[MAXPATHLEN];
   #if 0
  +        int     s;
   	char	line[132];
   	char	buf[132];
   	int	full;
  @@ -275,18 +277,16 @@
   			sizeof(int32) );
   		My.id = ntohl( My.id );
   
  -		s = strlen( machine_name );
  -		if( s > sizeof(My.name) ) s = sizeof(My.name);
  -		memcpy(My.name, machine_name, s );
  +		name_len = strlen( machine_name );
  +		if( name_len > sizeof(My.name) ) name_len = sizeof(My.name);
  +		memcpy(My.name, machine_name, name_len );
   		Alarm( CONF, "Conf_init: My name: %s, id: %d\n",
   			My.name, My.id );
   		return( 1 );
   	}else{
  -		int	s;
  -
  -		s = strlen( my_name );
  -		if( s > sizeof(My.name) ) s = sizeof(My.name);
  -		memcpy(My.name, my_name, s );
  +		name_len = strlen( my_name );
  +		if( name_len > sizeof(My.name) ) name_len = sizeof(My.name);
  +		memcpy(My.name, my_name, name_len );
   		i = Conf_proc_by_name( My.name, &My );
   		if( i < 0  ) Alarm( EXIT,
   				"Conf_init: My proc %s is not in configuration \n",
  @@ -563,11 +563,11 @@
           SocketPortReuse = state;
   }
   
  -static void set_param_if_valid(char **param, char *value, char *description, int max_value_len)
  +static void set_param_if_valid(char **param, char *value, char *description, unsigned int max_value_len)
   {
           if (value != NULL && *value != '\0')
           {
  -                int len = strlen(value);
  +                unsigned int len = strlen(value);
                   char *old_value = *param;
                   char *buf;
                   if (len > max_value_len)
  
  
  
  1.17      +1 -1      spread/daemon/groups.c
  
  Index: groups.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/groups.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- groups.c	16 Apr 2004 16:50:34 -0000	1.16
  +++ groups.c	23 Sep 2004 23:15:18 -0000	1.17
  @@ -2251,7 +2251,7 @@
   {
   	char	name[MAX_GROUP_NAME];
   	char	*pn, *prvn;
  -	int	priv_name_len, proc_name_len;
  +	unsigned int	priv_name_len, proc_name_len;
   	int	i,legal_private_name;
   
           memcpy(name, private_group_name, MAX_GROUP_NAME );
  
  
  
  1.12      +3 -3      spread/daemon/network.c
  
  Index: network.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/network.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- network.c	5 Mar 2004 00:32:46 -0000	1.11
  +++ network.c	23 Sep 2004 23:15:18 -0000	1.12
  @@ -79,7 +79,7 @@
   static	sp_time		Partition_timeout 	= { 60, 0};
   static	int		My_index;
   
  -static	void		Clear_partition();
  +static	void		Clear_partition(int dummy, void *dummy_p);
   static	int		In_my_component( int32	proc_id );
   static	void		Flip_pack( packet_header *pack_ptr );
   static	void		Flip_token( token_header *token_ptr );
  @@ -96,7 +96,7 @@
   	My = Conf_my();
   
   	My_index = Conf_proc_by_id( My.id, &dummy_proc );
  -	Clear_partition();
  +	Clear_partition(0, NULL);
   
   	if( Cn.segments[My.seg_index].num_procs > 1 )
   	{
  @@ -673,7 +673,7 @@
   	return( &(Token_channel[0]) );
   }
   
  -static	void	Clear_partition()
  +static	void	Clear_partition(int dummy, void *dummy_p)
   {
   	int	i;
   
  
  
  
  1.17      +1 -1      spread/daemon/session.c
  
  Index: session.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/session.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- session.c	5 Mar 2004 00:32:46 -0000	1.16
  +++ session.c	23 Sep 2004 23:15:18 -0000	1.17
  @@ -1014,7 +1014,7 @@
   {
           char        ip[16];
           char        response;
  -        int         name_len;
  +        unsigned int    name_len;
           char	private_group_name[MAX_GROUP_NAME];
   
           if (!Is_preauth_session(Sessions[ses].status) )
  
  
  
  1.5       +1 -1      spread/daemon/simple_user.c
  
  Index: simple_user.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/simple_user.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- simple_user.c	5 Mar 2004 00:32:46 -0000	1.4
  +++ simple_user.c	23 Sep 2004 23:15:18 -0000	1.5
  @@ -56,7 +56,7 @@
   int main( int argc, char *argv[] )
   {
   	int	ret;
  -	int	mess_len;
  +	unsigned int	mess_len;
   	char	mess[200];
   
   
  
  
  
  1.13      +16 -13    spread/daemon/sp.c
  
  Index: sp.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/sp.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- sp.c	23 Sep 2004 18:07:34 -0000	1.12
  +++ sp.c	23 Sep 2004 23:15:18 -0000	1.13
  @@ -338,7 +338,8 @@
           struct auth_method_info auth_methods[MAX_AUTH_METHODS];
   	int			p;
   	int			s;
  -	int			ret, len, i;
  +	int			ret, i;
  +        unsigned int            len;
   	int			sp_v1, sp_v2, sp_v3;
   	char			l;
   	int32			on;
  @@ -891,16 +892,17 @@
   	int		ret;
   	char		send_group[MAX_GROUP_NAME];
   	scatter		send_scat;
  -	int		len;
  +	unsigned int	len;
   	int		i;
   
  -	send_group[MAX_GROUP_NAME-1]=0;
  -	strncpy(send_group, group, MAX_GROUP_NAME-1);
  -	len = strlen( send_group );
  -	if( len == 0 ) return( ILLEGAL_GROUP );
  +	len = strlen( group );
  +	if ( len == 0 ) return( ILLEGAL_GROUP );
  +        if ( len >= MAX_GROUP_NAME ) return( ILLEGAL_GROUP );
   	for( i=0; i < len; i++ )
  -		if( send_group[i] < 36 || send_group[i] > 126 ) return( ILLEGAL_GROUP );
  +		if( group[i] < 36 || group[i] > 126 ) return( ILLEGAL_GROUP );
   
  +	send_group[MAX_GROUP_NAME-1]=0;
  +	strncpy(send_group, group, MAX_GROUP_NAME-1);
   	send_scat.num_elements = 0;
   
   	ret = SP_internal_multicast( mbox, JOIN_MESS, 1, (const char (*)[MAX_GROUP_NAME])send_group, 0, &send_scat );
  @@ -912,16 +914,17 @@
   	int		ret;
   	char		send_group[MAX_GROUP_NAME];
   	scatter		send_scat;
  -	int		len;
  +	unsigned int	len;
   	int		i;
   
  -	send_group[MAX_GROUP_NAME-1]=0;
  -	strncpy(send_group, group, MAX_GROUP_NAME-1);
  -	len = strlen( send_group );
  -	if( len == 0 ) return( ILLEGAL_GROUP );
  +	len = strlen( group );
  +	if ( len == 0 ) return( ILLEGAL_GROUP );
  +	if ( len >= MAX_GROUP_NAME ) return( ILLEGAL_GROUP );
   	for( i=0; i < len; i++ )
  -		if( send_group[i] < 36 || send_group[i] > 126 ) return( ILLEGAL_GROUP );
  +		if( group[i] < 36 || group[i] > 126 ) return( ILLEGAL_GROUP );
   
  +	send_group[MAX_GROUP_NAME-1]=0;
  +	strncpy(send_group, group, MAX_GROUP_NAME-1);
   	send_scat.num_elements = 0;
   
   	ret = SP_internal_multicast( mbox, LEAVE_MESS, 1, (const char (*)[MAX_GROUP_NAME])send_group, 0, &send_scat );
  
  
  
  1.8       +4 -5      spread/daemon/user.c
  
  Index: user.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/user.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- user.c	16 Apr 2004 17:58:44 -0000	1.7
  +++ user.c	23 Sep 2004 23:15:18 -0000	1.8
  @@ -71,7 +71,7 @@
   static  char    Private_group[MAX_GROUP_NAME];
   static  mailbox Mbox;
   static	int	Num_sent;
  -static	int	Previous_len;
  +static	unsigned int	Previous_len;
   
   static  int     To_exit = 0;
   
  @@ -210,7 +210,7 @@
   	char	group[80];
   	char	groups[10][MAX_GROUP_NAME];
   	int	num_groups;
  -	int	mess_len;
  +	unsigned int	mess_len;
   	int	ret;
   	int	i;
   
  @@ -282,12 +282,11 @@
   			printf("enter size of each message: ");
   			ret = (int) fgets( mess, 200, stdin );
   			if( ret==0 ) Bye();
  -			ret=sscanf(mess, "%d", &mess_len );
  +			ret=sscanf(mess, "%u", &mess_len );
   			if( ret !=1 ) mess_len = Previous_len;
  -			if( mess_len < 0 ) mess_len = 0;
                           if( mess_len > MAX_MESSLEN ) mess_len = MAX_MESSLEN;
   			Previous_len = mess_len;
  -			printf("sending 10 messages of %d bytes\n", mess_len );
  +			printf("sending 10 messages of %u bytes\n", mess_len );
   			for( i=0; i<10; i++ )
   			{
   				Num_sent++;
  
  
  
  1.58      +6 -0      spread/daemon/Readme.txt
  
  Index: Readme.txt
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/Readme.txt,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- Readme.txt	23 Sep 2004 18:07:34 -0000	1.57
  +++ Readme.txt	23 Sep 2004 23:15:18 -0000	1.58
  @@ -68,6 +68,12 @@
      to SP_recv* was too small, the mess_type field returned would be truncated
      and the sender field was not returned. They are both now returned correctly.
      Bug report and partial fix provided by John Schultz. 
  +7) Fix bug where SP_Join and SP_Leave do not report an error if a group name
  +   is too long (instead they truncated it) Reported with fix by David Parker.
  +   ** Warning, this could break buggy applications who use long groups and 
  +      assume the name is truncated. 
  +8) Cleanup compile warnings where E_queue() used with no-parameter functions 
  +   (not all uses fixed) and fix incorrect use of signed int with strlen().
   
   SOURCE INSTALL:
   ---------------
  
  
  




More information about the Spread-cvs mailing list