netutils/webserver: Fix the compiler error when -no-builtin is removed

Error: httpd.c:671:7: error: 'strncpy' output truncated before terminating nul copying 12 bytes from a string of the same length [-Werror=stringop-truncation]
  671 |       strncpy(pstate->ht_filename, "/" CONFIG_NETUTILS_HTTPD_INDEX,
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  672 |               strlen("/" CONFIG_NETUTILS_HTTPD_INDEX));
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-03-03 02:56:05 +08:00 committed by Petro Karashchenko
parent f0bb6cf914
commit 997379d14e

View File

@ -668,8 +668,8 @@ static inline int httpd_parse(struct httpd_state *pstate)
#ifdef CONFIG_NETUTILS_HTTPD_CLASSIC
if (0 == strcmp(pstate->ht_filename, "/"))
{
strncpy(pstate->ht_filename, "/" CONFIG_NETUTILS_HTTPD_INDEX,
strlen("/" CONFIG_NETUTILS_HTTPD_INDEX));
strlcpy(pstate->ht_filename, "/" CONFIG_NETUTILS_HTTPD_INDEX,
sizeof(pstate->ht_filename));
}
#endif