This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=75d0fbec710d21965cb0d2c05bd43b26ca47842b

commit 75d0fbec710d21965cb0d2c05bd43b26ca47842b
Author: Guillem Jover <[email protected]>
AuthorDate: Sun Jan 8 03:39:24 2023 +0100

    libdpkg: Move compression level max bound check from dpkg-deb
    
    The compression level max bound check is specific to each compressor,
    and we cannot simply use a single max bound for every compressor. Move
    the check into the compressor_check_params() function where we can check
    whether it is coherent with the compressor requested.
    
    The dpkg_options_parse_arg_int() already makes sure we get a sanitized
    value that is 0 or larger but not larger than INT_MAX.
---
 lib/dpkg/compress.c | 6 ++++++
 src/deb/main.c      | 8 +-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lib/dpkg/compress.c b/lib/dpkg/compress.c
index 3822a5520..e052d0bd8 100644
--- a/lib/dpkg/compress.c
+++ b/lib/dpkg/compress.c
@@ -1028,6 +1028,12 @@ compressor_check_params(struct compress_params *params, 
struct dpkg_error *err)
 {
        compressor_fixup_params(params);
 
+       if (params->level > 9) {
+               dpkg_put_error(err, _("invalid compression level %d"),
+                              params->level);
+               return false;
+       }
+
        if (params->strategy == COMPRESSOR_STRATEGY_NONE)
                return true;
 
diff --git a/src/deb/main.c b/src/deb/main.c
index 80886f651..416eba30f 100644
--- a/src/deb/main.c
+++ b/src/deb/main.c
@@ -187,13 +187,7 @@ parse_compress_level(const char *str)
 static void
 set_compress_level(const struct cmdinfo *cip, const char *value)
 {
-  long level;
-
-  level = dpkg_options_parse_arg_int(cip, value);
-  if (level < 0 || level > 9)
-    badusage(_("invalid compression level for -%c: %ld"), cip->oshort, level);
-
-  compress_params.level = level;
+  compress_params.level = dpkg_options_parse_arg_int(cip, value);
 }
 
 static void

-- 
Dpkg.Org's dpkg

Reply via email to