Bläddra i källkod

dpkg-split: Correctly set the last part split size

The partsize for each part should be the same, the code was wrongly
setting the partsize to the real size of the data being written.

Regression introduced in commit 506dd27b56a570e019e90974ea285fe4fd2f8bf8.
Guillem Jover 15 år sedan
förälder
incheckning
438e5813ca
2 ändrade filer med 7 tillägg och 4 borttagningar
  1. 1 0
      debian/changelog
  2. 6 4
      dpkg-split/split.c

+ 1 - 0
debian/changelog

@@ -1,6 +1,7 @@
 dpkg (1.16.0.2) UNRELEASED; urgency=low
 
   * Fix dpkg-split --auto to not fail when opening the new depot file.
+  * Fix dpkg-split to correctly set the last part split size.
 
  -- Guillem Jover <guillem@debian.org>  Fri, 15 Apr 2011 23:57:19 +0200
 

+ 6 - 4
dpkg-split/split.c

@@ -119,7 +119,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
 	char *package, *version;
 	int nparts, curpart;
 	off_t partsize;
-	off_t last_partsize;
+	off_t cur_partsize, last_partsize;
 	char *prefixdir = NULL, *msdos_prefix = NULL;
 	struct varbuf file_dst = VARBUF_INIT;
 	struct varbuf partmagic = VARBUF_INIT;
@@ -186,9 +186,11 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
 		}
 
 		if (curpart == nparts)
-			partsize = last_partsize;
+			cur_partsize = last_partsize;
+		else
+			cur_partsize = partsize;
 
-		if (partsize > maxpartsize) {
+		if (cur_partsize > maxpartsize) {
 			ohshit(_("Header is too long, making part too long. "
 			       "Your package name or version\n"
 			       "numbers must be extraordinarily long, "
@@ -215,7 +217,7 @@ mksplit(const char *file_src, const char *prefix, off_t maxpartsize,
 		/* Write the data part. */
 		varbuf_printf(&partname, "data.%d", curpart);
 		dpkg_ar_member_put_file(file_dst.buf, fd_dst, partname.buf,
-		                        fd_src, partsize);
+		                        fd_src, cur_partsize);
 		varbuf_reset(&partname);
 
 		close(fd_dst);