]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
http2: flatten code style
authorPhilippe Antoine <contact@catenacyber.fr>
Wed, 15 Sep 2021 14:20:56 +0000 (16:20 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 1 Oct 2021 06:10:04 +0000 (08:10 +0200)
src/app-layer-htp.c

index 313a402d9624613512c875e6e9a349bfdd675ebb..9daa5e7adf5a9a3169a69daae774fc3d8aef05c0 100644 (file)
@@ -925,23 +925,25 @@ static AppLayerResult HTPHandleResponseData(Flow *f, void *htp_state,
                 if (tx != NULL && tx->response_status_number == 101) {
                     htp_header_t *h =
                             (htp_header_t *)htp_table_get_c(tx->response_headers, "Upgrade");
-                    if (h != NULL) {
-                        if (bstr_cmp_c(h->value, "h2c") == 0) {
-                            uint16_t dp = 0;
-                            if (tx->request_port_number != -1) {
-                                dp = (uint16_t)tx->request_port_number;
-                            }
-                            consumed = htp_connp_res_data_consumed(hstate->connp);
-                            AppLayerRequestProtocolChange(hstate->f, dp, ALPROTO_HTTP2);
-                            // During HTTP2 upgrade, we may consume the HTTP1 part of the data
-                            // and we need to parser the remaining part with HTTP2
-                            if (consumed > 0 && consumed < input_len) {
-                                SCReturnStruct(
-                                        APP_LAYER_INCOMPLETE(consumed, input_len - consumed));
-                            }
-                            SCReturnStruct(APP_LAYER_OK);
-                        }
+                    if (h == NULL) {
+                        break;
+                    }
+                    if (bstr_cmp_c(h->value, "h2c") != 0) {
+                        break;
+                    }
+                    uint16_t dp = 0;
+                    if (tx->request_port_number != -1) {
+                        dp = (uint16_t)tx->request_port_number;
+                    }
+                    consumed = htp_connp_res_data_consumed(hstate->connp);
+                    AppLayerRequestProtocolChange(hstate->f, dp, ALPROTO_HTTP2);
+                    // During HTTP2 upgrade, we may consume the HTTP1 part of the data
+                    // and we need to parser the remaining part with HTTP2
+                    if (consumed > 0 && consumed < input_len) {
+                        SCReturnStruct(
+                                APP_LAYER_INCOMPLETE(consumed, input_len - consumed));
                     }
+                    SCReturnStruct(APP_LAYER_OK);
                 }
                 break;
             default: