From cbafcfabf2eb593de9ee95483da93f278c9ff1ee Mon Sep 17 00:00:00 2001 From: David Steele Date: Mon, 7 Aug 2023 12:38:33 +0100 Subject: [PATCH] Remove UNCONSTIFY() from gz compression module. The ZLIB_CONST macro may be used since 1.2.5.2 (17 Dec 2011) to specify that the input buffers are const. This is sufficiently old to cover all non-EOL distributions, i.e. everything we test on. Compiling on older distributions may generate warnings but will continue to work. --- meson.build | 2 ++ src/build.auto.h.in | 3 +++ src/common/compress/gz/compress.c | 2 +- src/common/compress/gz/decompress.c | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index fe75a560d..09f544095 100644 --- a/meson.build +++ b/meson.build @@ -165,6 +165,8 @@ lib_yaml = dependency('yaml-0.1') # Find required gz library lib_z = dependency('zlib') +configuration.set('ZLIB_CONST', true, description: 'Require zlib const input buffer') + # Find optional libssh2 library lib_ssh2 = dependency('libssh2', required: false) diff --git a/src/build.auto.h.in b/src/build.auto.h.in index 85d3fe110..d32595451 100644 --- a/src/build.auto.h.in +++ b/src/build.auto.h.in @@ -29,6 +29,9 @@ Build Flags Generated by Configure // Configuration path #undef CFGOPTDEF_CONFIG_PATH +// Require zlib const input buffer +#define ZLIB_CONST + // Indicate that a function does not return #define FN_NO_RETURN __attribute__((__noreturn__)) diff --git a/src/common/compress/gz/compress.c b/src/common/compress/gz/compress.c index d372cafa1..246305636 100644 --- a/src/common/compress/gz/compress.c +++ b/src/common/compress/gz/compress.c @@ -104,7 +104,7 @@ gzCompressProcess(THIS_VOID, const Buffer *uncompressed, Buffer *compressed) this->stream.avail_in = (unsigned int)bufUsed(uncompressed); // Not all versions of zlib (and none by default) will accept const input buffers - this->stream.next_in = UNCONSTIFY(unsigned char *, bufPtrConst(uncompressed)); + this->stream.next_in = bufPtrConst(uncompressed); } } diff --git a/src/common/compress/gz/decompress.c b/src/common/compress/gz/decompress.c index 2df798447..2dedb75f1 100644 --- a/src/common/compress/gz/decompress.c +++ b/src/common/compress/gz/decompress.c @@ -90,7 +90,7 @@ gzDecompressProcess(THIS_VOID, const Buffer *compressed, Buffer *uncompressed) this->stream.avail_in = (unsigned int)bufUsed(compressed); // Not all versions of zlib (and none by default) will accept const input buffers - this->stream.next_in = UNCONSTIFY(unsigned char *, bufPtrConst(compressed)); + this->stream.next_in = bufPtrConst(compressed); } this->stream.avail_out = (unsigned int)bufRemains(uncompressed);