Skip to content

Commit 721cb6b

Browse files
authored
CI Update (awslabs#135)
* Quote TO_CMAKE_PATH args * Add build config file * Disable magic number check * Fix fuzz-found error involving pad length longer than payload length * Fix fuzz-found issue with resizing empty dynamic table
1 parent a75df0a commit 721cb6b

9 files changed

+33
-9
lines changed

.clang-tidy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
Checks: 'clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,bugprone-*,misc-*,google-runtime-int,fuchsia-restrict-system-includes,-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-alpha.*,-readability-else-after-return,-misc-unused-parameters'
2+
Checks: 'clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,bugprone-*,misc-*,google-runtime-int,fuchsia-restrict-system-includes,-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-alpha.*,-readability-else-after-return,-readability-magic-numbers,-misc-unused-parameters'
33
WarningsAsErrors: '*'
44
HeaderFilterRegex: '\./*'
55
FormatStyle: 'file'

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ project(aws-c-http C)
44
option(ENABLE_PROXY_INTEGRATION_TESTS "Whether to run the proxy integration tests that rely on a proxy server installed and running locally" OFF)
55

66
if (DEFINED CMAKE_PREFIX_PATH)
7-
file(TO_CMAKE_PATH ${CMAKE_PREFIX_PATH} CMAKE_PREFIX_PATH)
7+
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
88
endif()
99

1010
if (DEFINED CMAKE_INSTALL_PREFIX)
11-
file(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX} CMAKE_INSTALL_PREFIX)
11+
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
1212
endif()
1313

1414
if (UNIX AND NOT APPLE)

builder.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "aws-c-http",
3+
"upstream": [
4+
{ "name": "aws-c-io" },
5+
{ "name": "aws-c-compression" }
6+
],
7+
"downstream": [
8+
{ "name": "aws-c-auth" }
9+
]
10+
}

source/h2_frames.c

+8
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,10 @@ int aws_h2_frame_headers_decode(struct aws_h2_frame_headers *frame, struct aws_h
733733
goto read_error;
734734
}
735735

736+
if (frame->pad_length > decoder->payload.len) {
737+
goto protocol_error;
738+
}
739+
736740
/* Remove padding from payload */
737741
decoder->payload.len -= frame->pad_length;
738742
}
@@ -1183,6 +1187,10 @@ int aws_h2_frame_push_promise_decode(struct aws_h2_frame_push_promise *frame, st
11831187
goto read_error;
11841188
}
11851189

1190+
if (frame->pad_length > decoder->payload.len) {
1191+
goto protocol_error;
1192+
}
1193+
11861194
/* Remove padding from payload */
11871195
decoder->payload.len -= frame->pad_length;
11881196
}

source/hpack.c

+6
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ int aws_hpack_resize_dynamic_table(struct aws_hpack_context *context, size_t new
502502
return AWS_OP_ERR;
503503
}
504504

505+
/* Don't bother copying data if old buffer was of size 0 */
506+
if (AWS_UNLIKELY(context->dynamic_table.max_elements == 0)) {
507+
goto reset_dyn_table_state;
508+
}
509+
505510
/* Copy as much the above block as possible */
506511
size_t above_block_size = context->dynamic_table.max_elements - context->dynamic_table.index_0;
507512
if (above_block_size > new_max_elements) {
@@ -529,6 +534,7 @@ int aws_hpack_resize_dynamic_table(struct aws_hpack_context *context, size_t new
529534
aws_mem_release(context->allocator, context->dynamic_table.buffer);
530535

531536
/* Reset state */
537+
reset_dyn_table_state:
532538
if (context->dynamic_table.num_elements > new_max_elements) {
533539
context->dynamic_table.num_elements = new_max_elements;
534540
}

tests/test_h1_client.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ enum request_callback {
13011301
REQUEST_CALLBACK_COUNT,
13021302
};
13031303

1304-
static const int ERROR_FROM_CALLBACK_ERROR_CODE = 0xBEEFCAFE;
1304+
static const int ERROR_FROM_CALLBACK_ERROR_CODE = (int)0xBEEFCAFE;
13051305

13061306
struct error_from_callback_tester {
13071307
enum request_callback error_at;

tests/test_h1_decoder.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ static int s_h1_decode_messages_at_random_intervals(struct aws_allocator *alloca
569569
/* Just seed something for determinism. */
570570
srand(1);
571571

572-
for (int iter = 0; iter < AWS_ARRAY_SIZE(requests); ++iter) {
572+
for (size_t iter = 0; iter < AWS_ARRAY_SIZE(requests); ++iter) {
573573
struct aws_byte_cursor request = requests[iter];
574574

575575
struct aws_h1_decoder_params params;
@@ -711,7 +711,7 @@ static int s_h1_decode_bad_requests_and_assert_failure(struct aws_allocator *all
711711
/* Go ahead and add more cases here. */
712712
};
713713

714-
for (int iter = 0; iter < AWS_ARRAY_SIZE(requests); ++iter) {
714+
for (size_t iter = 0; iter < AWS_ARRAY_SIZE(requests); ++iter) {
715715
struct aws_byte_cursor request = requests[iter];
716716

717717
struct aws_h1_decoder_params params;
@@ -747,7 +747,7 @@ static int s_h1_decode_bad_responses_and_assert_failure(struct aws_allocator *al
747747
/* Go ahead and add more cases here. */
748748
};
749749

750-
for (int iter = 0; iter < AWS_ARRAY_SIZE(responses); ++iter) {
750+
for (size_t iter = 0; iter < AWS_ARRAY_SIZE(responses); ++iter) {
751751
struct aws_byte_cursor response = responses[iter];
752752

753753
struct aws_h1_decoder_params params;

tests/test_h1_server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ enum request_handler_callback {
10561056
REQUEST_HANDLER_CALLBACK_COUNT,
10571057
};
10581058

1059-
static const int ERROR_FROM_CALLBACK_ERROR_CODE = 0xBEEFCAFE;
1059+
static const int ERROR_FROM_CALLBACK_ERROR_CODE = (int)0xBEEFCAFE;
10601060

10611061
struct error_from_callback_tester {
10621062
enum request_handler_callback error_at;

tests/test_h2_frames.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int s_test_priority_init(struct frame_test_fixture *fixture) {
276276
/* clang-format on */
277277

278278
aws_byte_buf_write(&fixture->buffer, frame_header, sizeof(frame_header));
279-
aws_byte_buf_write_be32(&fixture->buffer, (1ull << 31) | stream_dependency);
279+
aws_byte_buf_write_be32(&fixture->buffer, (1ULL << 31) | stream_dependency);
280280
aws_byte_buf_write_u8(&fixture->buffer, dependency_weight);
281281

282282
/* Init packet */

0 commit comments

Comments
 (0)