git: 212c271999d9 - stable/13 - Fix too small sscanf output buffers in kbdmap
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Feb 2022 17:27:01 UTC
The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=212c271999d9921ee056e32487d8502df385b0aa commit 212c271999d9921ee056e32487d8502df385b0aa Author: Dimitry Andric <dim@FreeBSD.org> AuthorDate: 2022-02-06 15:25:11 +0000 Commit: Dimitry Andric <dim@FreeBSD.org> CommitDate: 2022-02-09 17:26:24 +0000 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 (cherry picked from commit e17fede8ff4629b5ff640ed660940b04c70da0b6) --- usr.sbin/kbdmap/kbdmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c index 4f99ba03c2c8..f5d8a1e25e3c 100644 --- a/usr.sbin/kbdmap/kbdmap.c +++ b/usr.sbin/kbdmap/kbdmap.c @@ -224,7 +224,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"); @@ -580,7 +580,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;