ncurses 6.0 - patch 20160910
[ncurses.git] / test / demo_terminfo.c
index e2f771a98bbad7052bca76f127a43303941416a6..c1fffc7048f057277dd0295c8f5fa63dfffc1f8e 100644 (file)
@@ -29,7 +29,7 @@
 /*
  * Author: Thomas E. Dickey
  *
 /*
  * Author: Thomas E. Dickey
  *
- * $Id: demo_terminfo.c,v 1.42 2016/06/18 23:57:33 tom Exp $
+ * $Id: demo_terminfo.c,v 1.44 2016/09/10 21:22:49 tom Exp $
  *
  * A simple demo of the terminfo interface.
  */
  *
  * A simple demo of the terminfo interface.
  */
@@ -95,8 +95,9 @@ static long total_s_values;
 static char *
 make_dbitem(char *p, char *q)
 {
 static char *
 make_dbitem(char *p, char *q)
 {
-    char *result = malloc(strlen(e_opt) + 2 + (size_t) (p - q));
-    sprintf(result, "%s=%.*s", e_opt, (int) (p - q), q);
+    size_t need = strlen(e_opt) + 2 + (size_t) (p - q);
+    char *result = malloc(need);
+    _nc_SPRINTF(result, _nc_SLIMIT(need) "%s=%.*s", e_opt, (int) (p - q), q);
     return result;
 }
 
     return result;
 }
 
@@ -396,9 +397,11 @@ demo_terminfo(char *name)
                            !strcmp(xterm_keys[n], "kRIT")) {
                            continue;
                        }
                            !strcmp(xterm_keys[n], "kRIT")) {
                            continue;
                        }
-                       sprintf(temp, "%.*s", 8, xterm_keys[n]);
+                       _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+                                   "%.*s", 8, xterm_keys[n]);
                    } else {
                    } else {
-                       sprintf(temp, "%.*s%d", 8, xterm_keys[n], mod);
+                       _nc_SPRINTF(temp, _nc_SLIMIT(sizeof(temp))
+                                   "%.*s%d", 8, xterm_keys[n], mod);
                    }
                    dumpit(temp, NULL);
                }
                    }
                    dumpit(temp, NULL);
                }
@@ -733,7 +736,7 @@ copy_code_list(NCURSES_CONST char *const *list)
                length += chunk;
            } else {
                result[count] = unused;
                length += chunk;
            } else {
                result[count] = unused;
-               strcpy(unused, list[count]);
+               _nc_STRCPY(unused, list[count], length);
                unused += chunk;
            }
        }
                unused += chunk;
            }
        }