瀏覽代碼

Don't read from name[-1].
* src/incremen.c (make_directory): Handle namelen == 0, since
find_directory_meta calls make_directory ("").

Paul Eggert 17 年之前
父節點
當前提交
48d83be336
共有 2 個文件被更改,包括 18 次插入12 次删除
  1. 9 3
      ChangeLog
  2. 9 9
      src/incremen.c

+ 9 - 3
ChangeLog

@@ -1,3 +1,9 @@
+2007-11-12  Jim Meyering  <meyering@redhat.com>
+
+	Don't read from name[-1].
+	* src/incremen.c (make_directory): Handle namelen == 0, since
+	find_directory_meta calls make_directory ("").
+
 2007-11-07  Sergey Poznyakoff  <gray@gnu.org.ua>
 2007-11-07  Sergey Poznyakoff  <gray@gnu.org.ua>
 
 
 	* bootstrap (checkout): Use URL of the gnulib CVS mirror.
 	* bootstrap (checkout): Use URL of the gnulib CVS mirror.
@@ -11,7 +17,7 @@
 	TAR_BLOCKING_FACTOR environment variable.
 	TAR_BLOCKING_FACTOR environment variable.
 	* doc/tar.texi: Update
 	* doc/tar.texi: Update
 	* NEWS: Update
 	* NEWS: Update
-	
+
 2007-10-30  Sergey Poznyakoff  <gray@gnu.org.ua>
 2007-10-30  Sergey Poznyakoff  <gray@gnu.org.ua>
 
 
 	* doc/Makefile.am: Use texi2html and the CVS version of gendocs.sh
 	* doc/Makefile.am: Use texi2html and the CVS version of gendocs.sh
@@ -41,9 +47,9 @@
 	* src/system.c (sys_exec_checkpoint_script): New function.
 	* src/system.c (sys_exec_checkpoint_script): New function.
 	(sys_exec_info_script): Restore SIGPIPE handler.
 	(sys_exec_info_script): Restore SIGPIPE handler.
 	* src/tar.c: (parse_opt): New options --hard-dereference,
 	* src/tar.c: (parse_opt): New options --hard-dereference,
-	--checkpoint-action. 
+	--checkpoint-action.
 	(decode_options): Call checkpoint_finish_compile.
 	(decode_options): Call checkpoint_finish_compile.
-	
+
 	* src/system.c (sys_exec_info_script): Initialize buf. Problem
 	* src/system.c (sys_exec_info_script): Initialize buf. Problem
 	reported by Bengt-Arne Fjellner.
 	reported by Bengt-Arne Fjellner.
 
 

+ 9 - 9
src/incremen.c

@@ -124,8 +124,8 @@ make_directory (const char *name)
   directory->orig = NULL;
   directory->orig = NULL;
   directory->flags = false;
   directory->flags = false;
   strcpy (directory->name, name);
   strcpy (directory->name, name);
-  if (ISSLASH (directory->name[namelen-1]))
-    directory->name[namelen-1] = 0;
+  if (namelen && ISSLASH (directory->name[namelen - 1]))
+    directory->name[namelen - 1] = 0;
   directory->tagfile = NULL;
   directory->tagfile = NULL;
   return directory;
   return directory;
 }
 }
@@ -336,7 +336,7 @@ procdir (char *name_buffer, struct stat *stat_data,
 
 
   {
   {
     const char *tag_file_name;
     const char *tag_file_name;
-    
+
     switch (check_exclusion_tags (name_buffer, &tag_file_name))
     switch (check_exclusion_tags (name_buffer, &tag_file_name))
       {
       {
       case exclusion_tag_all:
       case exclusion_tag_all:
@@ -355,13 +355,13 @@ procdir (char *name_buffer, struct stat *stat_data,
 			       _("contents not dumped"));
 			       _("contents not dumped"));
 	directory->children = NO_CHILDREN;
 	directory->children = NO_CHILDREN;
 	break;
 	break;
-	
+
       case exclusion_tag_under:
       case exclusion_tag_under:
 	exclusion_tag_warning (name_buffer, tag_file_name,
 	exclusion_tag_warning (name_buffer, tag_file_name,
 			       _("contents not dumped"));
 			       _("contents not dumped"));
 	directory->tagfile = tag_file_name;
 	directory->tagfile = tag_file_name;
 	break;
 	break;
-	
+
       case exclusion_tag_none:
       case exclusion_tag_none:
 	break;
 	break;
       }
       }
@@ -507,7 +507,7 @@ scan_directory (char *dir, dev_t device)
   size_t name_length;		/* used length in name_buffer */
   size_t name_length;		/* used length in name_buffer */
   struct stat stat_data;
   struct stat stat_data;
   struct directory *directory;
   struct directory *directory;
-  
+
   if (! dirp)
   if (! dirp)
     savedir_error (dir);
     savedir_error (dir);
 
 
@@ -531,7 +531,7 @@ scan_directory (char *dir, dev_t device)
 
 
   directory = procdir (name_buffer, &stat_data, device, NO_CHILDREN, false,
   directory = procdir (name_buffer, &stat_data, device, NO_CHILDREN, false,
 		       NULL);
 		       NULL);
-  
+
   if (dirp && directory->children != NO_CHILDREN)
   if (dirp && directory->children != NO_CHILDREN)
     {
     {
       char  *entry;	/* directory entry being scanned */
       char  *entry;	/* directory entry being scanned */
@@ -1416,12 +1416,12 @@ try_purge_directory (char const *directory_name)
 	     This is an extra safety precaution. Besides, it might be
 	     This is an extra safety precaution. Besides, it might be
 	     necessary to extract from archives created with tar versions
 	     necessary to extract from archives created with tar versions
 	     prior to 1.19. */
 	     prior to 1.19. */
-	  
+
 	  if (*src)
 	  if (*src)
 	    src = safer_name_suffix (src, false, absolute_names_option);
 	    src = safer_name_suffix (src, false, absolute_names_option);
 	  if (*dst)
 	  if (*dst)
 	    dst = safer_name_suffix (dst, false, absolute_names_option);
 	    dst = safer_name_suffix (dst, false, absolute_names_option);
-	  
+
 	  if (*src == 0)
 	  if (*src == 0)
 	    src = temp_stub;
 	    src = temp_stub;
 	  else if (*dst == 0)
 	  else if (*dst == 0)