François Pinard пре 30 година
родитељ
комит
8d5c4b8415
3 измењених фајлова са 22 додато и 9 уклоњено
  1. 7 2
      src/create.c
  2. 14 6
      src/port.c
  3. 1 1
      src/version.c

+ 7 - 2
src/create.c

@@ -534,7 +534,7 @@ dump_file (p, curdev, toplevel)
 	  /*			sum += i;
 			if (sum < upperbound)
 				goto extend;*/
-	  if (index_offset + i < upperbound)
+	  if (index_offset + i <= upperbound)
 	    {
 	      index_offset += i;
 	      exhdr->ext_hdr.isextended++;
@@ -1055,7 +1055,7 @@ deal_with_sparse (name, header, nulls_at_end)
 		 * realloc the scratch area, since we've run out of room --
 		 */
 	  sparsearray = (struct sp_array *)
-	    realloc (sparsearray,
+	    ck_realloc (sparsearray,
 		     2 * sp_array_size * (sizeof (struct sp_array)));
 	  sp_array_size *= 2;
 	}
@@ -1105,6 +1105,11 @@ deal_with_sparse (name, header, nulls_at_end)
     }
   if (amidst_data)
     sparsearray[sparse_ind++].numbytes = numbytes;
+  else
+    {
+      sparsearray[sparse_ind].offset = offset-1;
+      sparsearray[sparse_ind++].numbytes = 1;
+    }
   close (fd);
 
   return sparse_ind - 1;

+ 14 - 6
src/port.c

@@ -177,14 +177,22 @@ rename (from, to)
 {
   struct stat from_stats;
 
-  if (stat (from, &from_stats) == 0)
+  if (stat (from, &from_stats))
+    return -1;
+
+  if (unlink (to) && errno != ENOENT)
+    return -1;
+
+  if (link (from, to))
+    return -1;
+
+  if (unlink (from) && errno != ENOENT)
     {
-      if (unlink (to) && errno != ENOENT)
-	return -1;
-      if (link (from, to) == 0 && (unlink (from) == 0 || errno == ENOENT))
-	return 0;
+      unlink (to);
+      return -1;
     }
-  return -1;
+
+  return 0;
 }
 #endif
 

+ 1 - 1
src/version.c

@@ -17,4 +17,4 @@ You should have received a copy of the GNU General Public License
 along with GNU Tar; see the file COPYING.  If not, write to
 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
    
-char version_string[] = "GNU tar version 1.10.14";
+char version_string[] = "GNU tar version 1.10.15";