You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/03 10:49:40 UTC

[incubator-nuttx-apps] branch master updated: netutils/webserver: Fix the compiler error when -no-builtin is removed

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 997379d  netutils/webserver: Fix the compiler error when -no-builtin is removed
997379d is described below

commit 997379d14e1d1da2aa2b81828f6500e1e03d14d2
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Mar 3 02:56:05 2022 +0800

    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 <xi...@xiaomi.com>
---
 netutils/webserver/httpd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/netutils/webserver/httpd.c b/netutils/webserver/httpd.c
index 0ffcbf8..6e74836 100644
--- a/netutils/webserver/httpd.c
+++ b/netutils/webserver/httpd.c
@@ -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