bug in dump

utzoo!watmath!watcgl!dmmartindale utzoo!watmath!watcgl!dmmartindale
Tue Dec 7 17:55:37 AEST 1982


When specifying the device to be dumped, you can give either the device
name or the name that the filesystem is normally mounted on.  Unfortunately,
the code which does the string matching is wrong, and so "/u" will match
"/usr".  Basically, strncmp is passed the wrong length and ends up
checking to see if one name is a prefix of the other.  The following diff
shows the needed changes from the 4.1BSD distribution (don't expect line
numbers to match though).

	Dave Martindale

*** /usr/distr/4.1/usr/src/cmd/dump/dumpoptr.c	Thu Dec 18 03:52:59 1980
--- dumpoptr.c	Tue Dec  7 17:00:46 1982
***************
*** 230,236
  			(((1.0*(tnow - tstart_writing))/blockswritten) * esize);
  		msg("%3.2f%% done, finished in %d:%02d\n",
  			(blockswritten*100.0)/esize,
! 			deltat/3600, (deltat%3600)/60);
  	}
  }
  

--- 230,236 -----
  			(((1.0*(tnow - tstart_writing))/blockswritten) * esize);
  		msg("%3.2f%% done, finished in %d:%02d\n",
  			(blockswritten*100.0)/esize,
! 			(int)deltat/3600, ((int)deltat%3600)/60);
  	}
  }
  
***************
*** 315,321
  {
  	register	struct	fstab *dt;
  			int	i;
- 			int	keylength;
  			char	*rawname();
  
  	keylength = min(strlen(key), sizeof (dt->fs_file));

--- 315,320 -----
  {
  	register	struct	fstab *dt;
  			int	i;
  			char	*rawname();
  
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
***************
*** 318,324
  			int	keylength;
  			char	*rawname();
  
- 	keylength = min(strlen(key), sizeof (dt->fs_file));
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
  		if (strncmp(dt->fs_file, key, keylength) == 0)
  			return(dt);

--- 317,322 -----
  			int	i;
  			char	*rawname();
  
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
  		if (strncmp(dt->fs_file, key, sizeof(dt->fs_file)) == 0)
  			return(dt);
***************
*** 320,326
  
  	keylength = min(strlen(key), sizeof (dt->fs_file));
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
! 		if (strncmp(dt->fs_file, key, keylength) == 0)
  			return(dt);
  		if (strncmp(dt->fs_spec, key, keylength) == 0)
  			return(dt);

--- 318,324 -----
  			char	*rawname();
  
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
! 		if (strncmp(dt->fs_file, key, sizeof(dt->fs_file)) == 0)
  			return(dt);
  		if (strncmp(dt->fs_spec, key, sizeof(dt->fs_spec)) == 0)
  			return(dt);
***************
*** 322,328
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
  		if (strncmp(dt->fs_file, key, keylength) == 0)
  			return(dt);
! 		if (strncmp(dt->fs_spec, key, keylength) == 0)
  			return(dt);
  		if (strncmp(rawname(dt->fs_spec), key, keylength) == 0)
  			return(dt);

--- 320,326 -----
  	for (i = 0, dt = fstab; i < nfstab; i++, dt++){
  		if (strncmp(dt->fs_file, key, sizeof(dt->fs_file)) == 0)
  			return(dt);
! 		if (strncmp(dt->fs_spec, key, sizeof(dt->fs_spec)) == 0)
  			return(dt);
  		if (strcmp(rawname(dt->fs_spec), key) == 0)
  			return(dt);
***************
*** 324,330
  			return(dt);
  		if (strncmp(dt->fs_spec, key, keylength) == 0)
  			return(dt);
! 		if (strncmp(rawname(dt->fs_spec), key, keylength) == 0)
  			return(dt);
  
  		if (key[0] != '/'){

--- 322,328 -----
  			return(dt);
  		if (strncmp(dt->fs_spec, key, sizeof(dt->fs_spec)) == 0)
  			return(dt);
! 		if (strcmp(rawname(dt->fs_spec), key) == 0)
  			return(dt);
  
  		if (key[0] != '/'){
***************
*** 329,335
  
  		if (key[0] != '/'){
  			if (   (dt->fs_spec[0] == '/')
! 			    && (strncmp(dt->fs_spec+1, key, keylength) == 0))
  				return(dt);
  			if (   (dt->fs_file[0] == '/')
  			    && (strncmp(dt->fs_file+1, key, keylength) == 0))

--- 327,333 -----
  
  		if (key[0] != '/'){
  			if (   (dt->fs_spec[0] == '/')
! 			    && (strncmp(dt->fs_spec+1, key, sizeof(dt->fs_spec)-1) == 0))
  				return(dt);
  			if (   (dt->fs_file[0] == '/')
  			    && (strncmp(dt->fs_file+1, key, sizeof(dt->fs_file)-1) == 0))
***************
*** 332,338
  			    && (strncmp(dt->fs_spec+1, key, keylength) == 0))
  				return(dt);
  			if (   (dt->fs_file[0] == '/')
! 			    && (strncmp(dt->fs_file+1, key, keylength) == 0))
  				return(dt);
  		}
  	}

--- 330,336 -----
  			    && (strncmp(dt->fs_spec+1, key, sizeof(dt->fs_spec)-1) == 0))
  				return(dt);
  			if (   (dt->fs_file[0] == '/')
! 			    && (strncmp(dt->fs_file+1, key, sizeof(dt->fs_file)-1) == 0))
  				return(dt);
  		}
  	}



More information about the Comp.bugs.4bsd.ucb-fixes mailing list