Compilation fails with gcc 11+ and -Werror due to incompatible type redeclaration #442

Closed
opened 2026-01-29 20:43:58 +00:00 by claunia · 3 comments
Owner

Originally created by @istr on GitHub (Dec 27, 2022).

Due to an inconsistent redeclaration of BrotliEncoderCompress the compilation fails with gcc 11 and later when using -Werror=format-security.

This is due to the introduction of -Wvla-paremeter, see

The following patch resolves the issue

diff -Naur brotli-1.0.9/c/enc/encode.c brotli/c/enc/encode.c
--- brotli-1.0.9/c/enc/encode.c 2020-08-27 16:12:55.000000000 +0200
+++ brotli/c/enc/encode.c       2022-12-27 20:14:41.092276948 +0100
@@ -1470,8 +1470,9 @@
 
 BROTLI_BOOL BrotliEncoderCompress(
     int quality, int lgwin, BrotliEncoderMode mode, size_t input_size,
-    const uint8_t* input_buffer, size_t* encoded_size,
-    uint8_t* encoded_buffer) {
+    const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)],
+    size_t* encoded_size,
+    uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]) {
   BrotliEncoderState* s;
   size_t out_size = *encoded_size;
   const uint8_t* input_start = input_buffer;

This simply matches the function declaration in encode.c with what has been previously declared in encode.h.

@eustas you could use this patch as is (I've just signed the CLA) or I could prepare a PR if you tell me to do so.

Originally created by @istr on GitHub (Dec 27, 2022). Due to an inconsistent redeclaration of `BrotliEncoderCompress` the compilation fails with gcc 11 and later when using `-Werror=format-security`. This is due to the introduction of `-Wvla-paremeter`, see - https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc/Warning-Options.html#index-Wvla-parameter - https://www.gnu.org/software/gcc/gcc-11/changes.html The following patch resolves the issue ```patch diff -Naur brotli-1.0.9/c/enc/encode.c brotli/c/enc/encode.c --- brotli-1.0.9/c/enc/encode.c 2020-08-27 16:12:55.000000000 +0200 +++ brotli/c/enc/encode.c 2022-12-27 20:14:41.092276948 +0100 @@ -1470,8 +1470,9 @@ BROTLI_BOOL BrotliEncoderCompress( int quality, int lgwin, BrotliEncoderMode mode, size_t input_size, - const uint8_t* input_buffer, size_t* encoded_size, - uint8_t* encoded_buffer) { + const uint8_t input_buffer[BROTLI_ARRAY_PARAM(input_size)], + size_t* encoded_size, + uint8_t encoded_buffer[BROTLI_ARRAY_PARAM(*encoded_size)]) { BrotliEncoderState* s; size_t out_size = *encoded_size; const uint8_t* input_start = input_buffer; ``` This simply matches the function declaration in `encode.c` with what has been previously declared in `encode.h`. @eustas you could use this patch as is (I've just signed the CLA) or I could prepare a PR if you tell me to do so.
Author
Owner

@eustas commented on GitHub (Dec 27, 2022):

Oh, gosh, this thing again. Will fix soon.

@eustas commented on GitHub (Dec 27, 2022): Oh, gosh, this thing again. Will fix soon.
Author
Owner

@eustas commented on GitHub (Dec 30, 2022):

Isn't it fixed in #893?
We plan to have release soon, that will include this change.

@eustas commented on GitHub (Dec 30, 2022): Isn't it fixed in #893? We plan to have release soon, that will include this change.
Author
Owner

@istr commented on GitHub (Dec 30, 2022):

@eustas you are right, my search in the issues was not good enough -- sorry for the noise. 😊

@istr commented on GitHub (Dec 30, 2022): @eustas you are right, my search in the issues was not good enough -- sorry for the noise. :blush:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#442