]> git.kaiwu.me - nginx.git/commitdiff
SSI: avoid potential buffer overflow.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 18 Jul 2019 15:27:53 +0000 (18:27 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 18 Jul 2019 15:27:53 +0000 (18:27 +0300)
When "-" follows a parameter of maximum length, a single byte buffer
overflow happens, since the error branch does not check parameter length.
Fix is to avoid saving "-" to the parameter key, and instead use an error
message with "-" explicitly written.  The message is mostly identical to
one used in similar cases in the preequal state.

Reported by Patrick Wollgast.

src/http/modules/ngx_http_ssi_filter_module.c

index d608df9df55d79a49c230fb66f8d0bc163367f75..6737965d14f2f43ed2399348e9e11c11f557b295 100644 (file)
@@ -1254,9 +1254,9 @@ ngx_http_ssi_parse(ngx_http_request_t *r, ngx_http_ssi_ctx_t *ctx)
             case '-':
                 state = ssi_error_end0_state;
 
-                ctx->param->key.data[ctx->param->key.len++] = ch;
                 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
-                              "invalid \"%V\" parameter in \"%V\" SSI command",
+                              "unexpected \"-\" symbol after \"%V\" "
+                              "parameter in \"%V\" SSI command",
                               &ctx->param->key, &ctx->command);
                 break;