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

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

commit df48f0bb7319b9eb7c02559cb414d210297b362c
Author: Xiang Xiao <[email protected]>
AuthorDate: Sun Mar 6 20:01:14 2022 +0800

    system/termcurses: Fix the compiler warning
    
    tcurses_vt100.c: In function 'tcurses_vt100_move':
    Error: tcurses_vt100.c:121:48: error: '%d' directive writing between 1 and 
11 bytes into a region of size between 2 and 12 [-Werror=format-overflow=]
      121 | static const char *g_movecurs       = "\033[%d;%dH";  /* Move 
cursor to x,y */
          |                                                ^~
    tcurses_vt100.c:121:39: note: directive argument in the range [-2147483647, 
2147483647]
      121 | static const char *g_movecurs       = "\033[%d;%dH";  /* Move 
cursor to x,y */
          |                                       ^~~~~~~~~~~~~
    tcurses_vt100.c:795:9: note: 'sprintf' output between 7 and 27 bytes into a 
destination of size 16
      795 |         sprintf(str, g_movecurs, row + 1, col + 1);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 system/termcurses/tcurses_vt100.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/system/termcurses/tcurses_vt100.c 
b/system/termcurses/tcurses_vt100.c
index 059927b..3c7b491 100644
--- a/system/termcurses/tcurses_vt100.c
+++ b/system/termcurses/tcurses_vt100.c
@@ -782,7 +782,7 @@ static int tcurses_vt100_move(FAR struct termcurses_s *dev, 
int type,
   FAR struct tcurses_vt100_s *priv;
   int   ret = -ENOSYS;
   int   fd;
-  char  str[16];
+  char  str[32];
 
   priv = (FAR struct tcurses_vt100_s *)dev;
   fd   = priv->out_fd;
@@ -792,7 +792,7 @@ static int tcurses_vt100_move(FAR struct termcurses_s *dev, 
int type,
   switch (type)
     {
       case TCURS_MOVE_YX:
-        sprintf(str, g_movecurs, row + 1, col + 1);
+        snprintf(str, sizeof(str), g_movecurs, row + 1, col + 1);
         ret = write(fd, str, strlen(str));
         break;
 

Reply via email to