Fix too small sscanf output buffers in kbdmap

This fixes the following warnings from clang 14:

usr.sbin/kbdmap/kbdmap.c:241:16: error: 'sscanf' may overflow; destination buffer in argument 5 has size 20, but the corresponding specifier may require size 21 [-Werror,-Wfortify-source]
                            &a, &b, buf);
                                    ^
usr.sbin/kbdmap/kbdmap.c:615:8: error: 'sscanf' may overflow; destination buffer in argument 3 has size 64, but the corresponding specifier may require size 65 [-Werror,-Wfortify-source]
                            keym, lng, desc);
                            ^
usr.sbin/kbdmap/kbdmap.c:615:14: error: 'sscanf' may overflow; destination buffer in argument 4 has size 64, but the corresponding specifier may require size 65 [-Werror,-Wfortify-source]
                            keym, lng, desc);
                                  ^
usr.sbin/kbdmap/kbdmap.c:615:19: error: 'sscanf' may overflow; destination buffer in argument 5 has size 256, but the corresponding specifier may require size 257 [-Werror,-Wfortify-source]
                            keym, lng, desc);
                                       ^

In each case, the buffer being sscanf'd into is one byte too small.

MFC after:	 3 days
This commit is contained in:
Dimitry Andric 2022-02-06 16:25:11 +01:00
parent d310bf3867
commit e17fede8ff

View File

@ -225,7 +225,7 @@ get_extension(const char *name)
static char *
get_font(void)
{
char line[256], buf[20];
char line[256], buf[21];
char *fnt = NULL;
FILE *fp = fopen(sysconfig, "r");
@ -566,7 +566,7 @@ menu_read(void)
char *p;
int mark, num_keymaps, items, i;
char buffer[256], filename[PATH_MAX];
char keym[64], lng[64], desc[256];
char keym[65], lng[65], desc[257];
char dialect[64], lang_abk[64];
struct keymap *km;
struct keymap **km_sorted;