Skip to content

Commit

Permalink
Code review change: Set the max len of the copy buffer to 128
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshmurthy committed Dec 23, 2024
1 parent 8171c80 commit a9a0fd3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/observers/http2/http2_observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ static int on_header_recv_callback(qd_http2_decoder_connection_t *conn_state,
// The first X-Forwarded-For header is comma separated list, we will obtain the leftmost (the first) value (2001:db8:85a3:8d3:1319:8a2e:370:7348) in the list

// const uint8_t *value passed into this function is guaranteed to be NULL-terminated
char value_copy[valuelen+1];
strcpy(value_copy, (const char *)value);
char value_copy[128];
strncpy(value_copy, (const char *)value, 128);

Check warning

Code scanning / GNU C11

'strncpy' specified bound 128 equals destination size Warning

'strncpy' specified bound 128 equals destination size
// Get the first token (left-most)
char *first_token = strtok(value_copy, ",");
vflow_set_string(stream_info->vflow, VFLOW_ATTRIBUTE_SOURCE_HOST, first_token);
Expand Down

0 comments on commit a9a0fd3

Please sign in to comment.