From: tangxiaofeng <tangxiaofeng@kylinos.cn>
Date: Mon, 19 Oct 2026 21:03:13 +0000
Subject: [PATCH] Fix FTBFS with the C23 qualifier-generic strchr()

ngx_strchr() casts its argument to "const char *", so with a C23 conforming
glibc (>= 2.43) strchr() is a qualifier-generic macro (ISO C23) that returns a
"const char *" when the argument is const-qualified.  The pointer returned by
ngx_strchr() is assigned to a "char *" pointing into the writable buffer
allocated with ngx_palloc(), and nginx compiles modules with -Werror, so the
assignment is rejected with -Werror=discarded-qualifiers.  Convert the pointer
back explicitly with a cast; the generated code and the module behaviour are
unchanged on every toolchain and architecture.

---
Description: Fix FTBFS with the C23 qualifier-generic strchr()
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Forwarded: no
Last-Update: 2026-10-19

--- libnginx-mod-http-push-stream-0.6.0+dfsg.orig/src/ngx_http_push_stream_module_publisher.c
+++ libnginx-mod-http-push-stream-0.6.0+dfsg/src/ngx_http_push_stream_module_publisher.c
@@ -329,7 +329,11 @@ ngx_http_push_stream_channels_statistics
             return ngx_http_push_stream_send_only_header_response(r, NGX_HTTP_BAD_REQUEST, &NGX_HTTP_PUSH_STREAM_TOO_LARGE_CHANNEL_ID_MESSAGE);
         }
 
-        if ((pos = ngx_strchr(requested_channel->id->data, '*')) != NULL) {
+        // ngx_strchr() casts its argument to "const char *"; with a C23 conforming
+        // glibc (>= 2.43) strchr() is a qualifier-generic macro returning a
+        // "const char *", so convert it back before writing to the buffer (which
+        // is writable, allocated from the request pool)
+        if ((pos = (char *) ngx_strchr(requested_channel->id->data, '*')) != NULL) {
             ngx_str_t *aux = NULL;
             if (pos != (char *) requested_channel->id->data) {
                 *pos = '\0';
