]> git.kaiwu.me - nginx.git/commitdiff
Charset: disabled charset_map with utf-8 in the first column master
authorSergey Kandaurov <pluknet@nginx.com>
Thu, 2 Jul 2026 14:35:34 +0000 (18:35 +0400)
committerSergey Kandaurov <s.kandaurov@f5.com>
Fri, 3 Jul 2026 17:59:53 +0000 (21:59 +0400)
This undocumented configuration was never expected to work and
resulted in immediate segfaults.

Reported by ret2ddme.

src/http/modules/ngx_http_charset_filter_module.c

index e0115e1e4435794f1ee0b6da9ffdd38c6bbe2681..e2bbb0cacf8439b4f2e32ebfd1e9b1f0614b0088 100644 (file)
@@ -1197,6 +1197,13 @@ ngx_http_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
         return NGX_CONF_ERROR;
     }
 
         return NGX_CONF_ERROR;
     }
 
+    if (ngx_strcasecmp(value[1].data, (u_char *) "utf-8") == 0) {
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           "\"charset_map\" with \"utf-8\" charset "
+                           "should be given in the second column");
+        return NGX_CONF_ERROR;
+    }
+
     table = mcf->tables.elts;
     for (i = 0; i < mcf->tables.nelts; i++) {
         if ((src == table->src && dst == table->dst)
     table = mcf->tables.elts;
     for (i = 0; i < mcf->tables.nelts; i++) {
         if ((src == table->src && dst == table->dst)