]> git.kaiwu.me - nginx.git/commitdiff
gRPC: fixed possible sign extension of error and setting_value.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 22 Mar 2018 16:26:25 +0000 (19:26 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 22 Mar 2018 16:26:25 +0000 (19:26 +0300)
All cases are harmless and should not happen on valid values, though can
result in bad values being shown incorrectly in logs.

Found by Coverity (CID 143031114303121430313).

src/http/modules/ngx_http_grpc_module.c

index b6be9b874d30c88f0959cb30d2e6399e6a49379a..837ad9a2ea33816418474940fa5646fbd5bb7e02 100644 (file)
@@ -3212,7 +3212,7 @@ ngx_http_grpc_parse_rst_stream(ngx_http_request_t *r, ngx_http_grpc_ctx_t *ctx,
         switch (state) {
 
         case sw_start:
-            ctx->error = ch << 24;
+            ctx->error = (ngx_uint_t) ch << 24;
             state = sw_error_2;
             break;
 
@@ -3325,7 +3325,7 @@ ngx_http_grpc_parse_goaway(ngx_http_request_t *r, ngx_http_grpc_ctx_t *ctx,
             break;
 
         case sw_error:
-            ctx->error = ch << 24;
+            ctx->error = (ngx_uint_t) ch << 24;
             state = sw_error_2;
             break;
 
@@ -3555,7 +3555,7 @@ ngx_http_grpc_parse_settings(ngx_http_request_t *r, ngx_http_grpc_ctx_t *ctx,
             break;
 
         case sw_value:
-            ctx->setting_value = ch << 24;
+            ctx->setting_value = (ngx_uint_t) ch << 24;
             state = sw_value_2;
             break;