#983813 keymap.c: use "invalid" and "snprintf()"

Package:
src:nn
Source:
nn
Submitter:
Bjarni Ingi Gislason
Date:
2021-03-01 22:51:03 UTC
Severity:
normal
Tags:
#983813#5
Date:
2021-03-01 22:46:20 UTC
From:
To:
Dear Maintainer,

  Use "invalid" instead of "illegal", see GNU standard.

  Use "snprintf()" instead of "sprintf()".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 keymap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/keymap.c b/keymap.c
index bedeb34..fee9bbf 100644
--- a/keymap.c
+++ b/keymap.c
@@ -249,7 +249,7 @@ int             more_key_map[KEY_MAP_SIZE] = {
 /*
  * standard keyboard mappings for menu()
  *
- *	illegal command
+ *	invalid command
  *	redraw			^L, ^R
  *	continue		space
  *	continue no mark	return, newline
@@ -783,7 +783,8 @@ parse_key(char *str)
 char           *
 key_name(key_type c)
 {
-    static char     buf[10];
+#define    NBUF  10
+    static char     buf[NBUF];

     if (c >= NORMAL_KEYS && c <= (key_type) (KEY_MAP_SIZE - NATIONAL_KEYS)) {
 	switch (c) {
@@ -829,7 +830,7 @@ key_name(key_type c)
 	goto out;
     }
     if (data_bits < 8 && c >= NORMAL_KEYS) {
-	sprintf(buf, "0x%02x", (uint)c);
+	snprintf(buf, NBUF, "0x%02x", (uint)c);
 	goto out;
     }
     buf[0] = c;