ソースを参照

libdpkg: Fixup the compressor parameters during check instead of filter

This makes sure the compressor parameters are corrected for cases like
gzip with compression level 0, which requires to switch the parameters
before we get the compressor extension, otherwise we'll produce binary
packages not compliant with the deb(5) spec, even if they can be
unpacked by dpkg-deb itself (as zlib does not have a problem considering
uncompressed data a valid gzip file).

Closes: #718295
Guillem Jover 13 年 前
コミット
f1f9887b8f
共有2 個のファイルを変更した14 個の追加11 個の削除を含む
  1. 3 0
      debian/changelog
  2. 11 11
      lib/dpkg/compress.c

+ 3 - 0
debian/changelog

@@ -40,6 +40,9 @@ dpkg (1.17.6) UNRELEASED; urgency=low
   * Change default source package compressor for new formats (>= 2.0) to xz.
   * Change default source package compressor for new formats (>= 2.0) to xz.
   * Ignore the same packages in «dpkg-query --list» when computing the
   * Ignore the same packages in «dpkg-query --list» when computing the
     column width as when printing the entries. Closes: #734114
     column width as when printing the entries. Closes: #734114
+  * Do not produce .deb archives with uncompressed gzip members on
+    «dpkg-deb -Zgzip -z0», instead create them as non-compressed members,
+    as if -Znone had been passed, as documented. Closes: #718295
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * Swedish (Peter Krefting).
   * Swedish (Peter Krefting).

+ 11 - 11
lib/dpkg/compress.c

@@ -779,9 +779,20 @@ compressor_get_strategy(const char *name)
 	return compressor_strategy_unknown;
 	return compressor_strategy_unknown;
 }
 }
 
 
+static void
+compressor_fixup_params(struct compress_params *params)
+{
+	compressor(params->type)->fixup_params(params);
+
+	if (params->level < 0)
+		params->level = compressor(params->type)->default_level;
+}
+
 bool
 bool
 compressor_check_params(struct compress_params *params, struct dpkg_error *err)
 compressor_check_params(struct compress_params *params, struct dpkg_error *err)
 {
 {
+	compressor_fixup_params(params);
+
 	if (params->strategy == compressor_strategy_none)
 	if (params->strategy == compressor_strategy_none)
 		return true;
 		return true;
 
 
@@ -800,12 +811,6 @@ compressor_check_params(struct compress_params *params, struct dpkg_error *err)
 	return false;
 	return false;
 }
 }
 
 
-static void
-compressor_fixup_params(struct compress_params *params)
-{
-	compressor(params->type)->fixup_params(params);
-}
-
 void
 void
 decompress_filter(enum compressor_type type, int fd_in, int fd_out,
 decompress_filter(enum compressor_type type, int fd_in, int fd_out,
                   const char *desc_fmt, ...)
                   const char *desc_fmt, ...)
@@ -831,10 +836,5 @@ compress_filter(struct compress_params *params, int fd_in, int fd_out,
 	varbuf_vprintf(&desc, desc_fmt, args);
 	varbuf_vprintf(&desc, desc_fmt, args);
 	va_end(args);
 	va_end(args);
 
 
-	compressor_fixup_params(params);
-
-	if (params->level < 0)
-		params->level = compressor(params->type)->default_level;
-
 	compressor(params->type)->compress(fd_in, fd_out, params, desc.buf);
 	compressor(params->type)->compress(fd_in, fd_out, params, desc.buf);
 }
 }