zephyr/subsys/net/lib/http
Jukka Rissanen 0515bfff7a net: lib: http-client: Use memcpy() to avoid gcc warning
GCC 12.2.0 can give this warning (version 11.4.0 did not), when
CONFIG_SPEED_OPTIMIZATIONS=y

subsys/net/lib/http/http_client.c: In function 'http_send_data.constprop':
subsys/net/lib/http/http_client.c:114:33: warning: 'strncpy' specified
bound depends on the length of the source argument [-Wstringop-truncation]
  114 |                                 strncpy(send_buf + end_of_send,
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  115 |                                         data + end_of_data,
      |                                         ~~~~~~~~~~~~~~~~~~~
  116 |                                         remaining);
      |                                         ~~~~~~~~~~
subsys/net/lib/http/http_client.c:87:41: note: length computed here
   87 |                         remaining_len = strlen(data + end_of_data);
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~

The code properly checks that we do not overwrite the destination
buffer even if we use the source buffer length to determine how much
to copy. One possible fix is to use memcpy() or strcpy(), I opted
to use memcpy() because it has the length option which feels more
natural.

Fixes #79326

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-10-04 13:24:17 -05:00
..
headers net: lib: http_server: allow application to send headers/response code 2024-09-23 12:00:54 +02:00
CMakeLists.txt net: lib: http_server: allow application to access request headers 2024-09-06 11:27:37 -04:00
http_client.c net: lib: http-client: Use memcpy() to avoid gcc warning 2024-10-04 13:24:17 -05:00
http_hpack.c net: lib: http_server: Fix possible NULL pointer dereference 2024-06-24 12:41:22 -04:00
http_huffman.c net: lib: http_server: Add HPACK and Huffman code encoder/decoder 2024-04-30 13:25:22 +02:00
http_parser_url.c net: change controlling expressions in while to Boolean 2024-06-11 20:03:16 +03:00
http_parser.c net: change controlling expressions in while to Boolean 2024-06-11 20:03:16 +03:00
http_server_core.c net: lib: http_server: allow application to send headers/response code 2024-09-23 12:00:54 +02:00
http_server_http1.c net: lib: http_server: fix snprintk issue of size_t 2024-09-25 04:00:02 -04:00
http_server_http2.c net: lib: http_server: remove dynamic resource data buffer 2024-09-23 12:00:54 +02:00
http_server_ws.c net: http_server: Add websocket support 2024-05-08 15:02:16 -05:00
iterables_content_type.ld net: lib: http_server: allow application to access request headers 2024-09-06 11:27:37 -04:00
iterables_header_capture.ld net: lib: http_server: allow application to access request headers 2024-09-06 11:27:37 -04:00
Kconfig net: lib: http_server: allow application to send headers/response code 2024-09-23 12:00:54 +02:00
README_http_parser