Kaynağa Gözat

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 yıl önce
ebeveyn
işleme
f1f9887b8f
2 değiştirilmiş dosya ile 14 ekleme ve 11 silme
  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.
   * Ignore the same packages in «dpkg-query --list» when computing the
     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 ]
   * Swedish (Peter Krefting).

+ 11 - 11
lib/dpkg/compress.c

@@ -779,9 +779,20 @@ compressor_get_strategy(const char *name)
 	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
 compressor_check_params(struct compress_params *params, struct dpkg_error *err)
 {
+	compressor_fixup_params(params);
+
 	if (params->strategy == compressor_strategy_none)
 		return true;
 
@@ -800,12 +811,6 @@ compressor_check_params(struct compress_params *params, struct dpkg_error *err)
 	return false;
 }
 
-static void
-compressor_fixup_params(struct compress_params *params)
-{
-	compressor(params->type)->fixup_params(params);
-}
-
 void
 decompress_filter(enum compressor_type type, int fd_in, int fd_out,
                   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);
 	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);
 }