Skip to content

Commit

Permalink
if amq not disconnect when return AMQP_STATUS_BAD_AMQP_DATA, maybe cr…
Browse files Browse the repository at this point in the history
…ash in consume_data when next receive data.

because it change state->target_size but not allocate state->inbound_buffer.

line 222 (bytes_consumed = consume_data(state, &received_data);)
  • Loading branch information
xiaobfly committed Jul 5, 2024
1 parent 9d642be commit 4fbd519
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions librabbitmq/amqp_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data,
return AMQP_STATUS_BAD_AMQP_DATA;
}

state->target_size = frame_size + HEADER_SIZE + FOOTER_SIZE;
if ((size_t)state->frame_max < state->target_size) {
frame_size = frame_size + HEADER_SIZE + FOOTER_SIZE;
if ((size_t)state->frame_max < frame_size) {
return AMQP_STATUS_BAD_AMQP_DATA;
}

Expand All @@ -279,7 +279,7 @@ int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data,
return AMQP_STATUS_NO_MEMORY;
}

amqp_pool_alloc_bytes(channel_pool, state->target_size,
amqp_pool_alloc_bytes(channel_pool, frame_size,
&state->inbound_buffer);
if (NULL == state->inbound_buffer.bytes) {
return AMQP_STATUS_NO_MEMORY;
Expand All @@ -288,7 +288,7 @@ int amqp_handle_input(amqp_connection_state_t state, amqp_bytes_t received_data,
raw_frame = state->inbound_buffer.bytes;

state->state = CONNECTION_STATE_BODY;

state->target_size = frame_size;
bytes_consumed += consume_data(state, &received_data);

/* do we have target_size data yet? if not, return with the
Expand Down

0 comments on commit 4fbd519

Please sign in to comment.