Blame SOURCES/kbd-2.4.0-covscan-fixes.patch

55a0e2
diff -up kbd-2.4.0/src/libkbdfile/kbdfile.c.orig kbd-2.4.0/src/libkbdfile/kbdfile.c
55a0e2
--- kbd-2.4.0/src/libkbdfile/kbdfile.c.orig	2020-11-11 13:44:48.000000000 +0100
55a0e2
+++ kbd-2.4.0/src/libkbdfile/kbdfile.c	2021-04-27 09:58:08.405671071 +0200
55a0e2
@@ -39,8 +39,10 @@ kbdfile_new(struct kbdfile_ctx *ctx)
55a0e2
 
55a0e2
 	if (!fp->ctx) {
55a0e2
 		fp->ctx = kbdfile_context_new();
55a0e2
-		if (!fp->ctx)
55a0e2
+		if (!fp->ctx) {
55a0e2
+			free(fp);
55a0e2
 			return NULL;
55a0e2
+		}
55a0e2
 		fp->flags |= KBDFILE_CTX_INITIALIZED;
55a0e2
 	}
55a0e2
 
55a0e2
@@ -69,7 +71,7 @@ kbdfile_get_pathname(struct kbdfile *fp)
55a0e2
 int
55a0e2
 kbdfile_set_pathname(struct kbdfile *fp, const char *pathname)
55a0e2
 {
55a0e2
-	strncpy(fp->pathname, pathname, sizeof(fp->pathname));
55a0e2
+	strncpy(fp->pathname, pathname, sizeof(fp->pathname) - 1);
55a0e2
 	return 0;
55a0e2
 }
55a0e2
 
55a0e2
@@ -385,7 +387,7 @@ kbdfile_find(const char *fnam, const cha
55a0e2
 	fp->flags &= ~KBDFILE_PIPE;
55a0e2
 
55a0e2
 	/* Try explicitly given name first */
55a0e2
-	strncpy(fp->pathname, fnam, sizeof(fp->pathname));
55a0e2
+	strncpy(fp->pathname, fnam, sizeof(fp->pathname) - 1);
55a0e2
 
55a0e2
 	if (!maybe_pipe_open(fp))
55a0e2
 		return 0;
55a0e2
diff -up kbd-2.4.0/src/libkeymap/common.c.orig kbd-2.4.0/src/libkeymap/common.c
55a0e2
--- kbd-2.4.0/src/libkeymap/common.c.orig	2019-06-24 13:55:23.000000000 +0200
55a0e2
+++ kbd-2.4.0/src/libkeymap/common.c	2021-04-27 09:58:08.405671071 +0200
55a0e2
@@ -139,6 +139,7 @@ init_array(struct lk_ctx *ctx, struct lk
55a0e2
 	rc = lk_array_init(ptr, size, 0);
55a0e2
 	if (rc < 0) {
55a0e2
 		ERR(ctx, _("unable to initialize array: %s"), strerror(rc));
55a0e2
+		free(ptr);
55a0e2
 		return -1;
55a0e2
 	}
55a0e2
 
55a0e2
diff -up kbd-2.4.0/src/libkfont/psffontop.c.orig kbd-2.4.0/src/libkfont/psffontop.c
55a0e2
--- kbd-2.4.0/src/libkfont/psffontop.c.orig	2020-04-27 17:53:01.000000000 +0200
55a0e2
+++ kbd-2.4.0/src/libkfont/psffontop.c	2021-04-27 09:59:14.170153676 +0200
55a0e2
@@ -235,6 +235,7 @@ kfont_read_psffont(struct kfont_context
55a0e2
 
55a0e2
 		if (psfhdr->mode > PSF1_MAXMODE) {
55a0e2
 			KFONT_ERR(ctx, _("Unsupported psf file mode (%d)"), psfhdr->mode);
55a0e2
+			free(psfhdr);
55a0e2
 			return -EX_DATAERR;
55a0e2
 		}
55a0e2
 		fontlen   = ((psfhdr->mode & PSF1_MODE512) ? 512 : 256);
55a0e2
@@ -251,6 +252,7 @@ kfont_read_psffont(struct kfont_context
55a0e2
 
55a0e2
 		if (psfhdr.version > PSF2_MAXVERSION) {
55a0e2
 			KFONT_ERR(ctx, _("Unsupported psf version (%d)"), psfhdr.version);
55a0e2
+			free(inputbuf);
55a0e2
 			return -EX_DATAERR;
55a0e2
 		}
55a0e2
 		fontlen   = assemble_uint32((unsigned char *)&psfhdr.length);
55a0e2
@@ -260,16 +262,20 @@ kfont_read_psffont(struct kfont_context
55a0e2
 		ftoffset  = assemble_uint32((unsigned char *)&psfhdr.headersize);
55a0e2
 		fontwidth = assemble_uint32((unsigned char *)&psfhdr.width);
55a0e2
 		utf8      = 1;
55a0e2
-	} else
55a0e2
+	} else {
55a0e2
+		free(inputbuf);
55a0e2
 		return -EX_DATAERR; /* not psf */
55a0e2
+	}
55a0e2
 
55a0e2
 	/* tests required - we divide by these */
55a0e2
 	if (fontlen == 0) {
55a0e2
 		KFONT_ERR(ctx, _("zero input font length?"));
55a0e2
+		free(inputbuf);
55a0e2
 		return -EX_DATAERR;
55a0e2
 	}
55a0e2
 	if (charsize == 0) {
55a0e2
 		KFONT_ERR(ctx, _("zero input character size?"));
55a0e2
+		free(inputbuf);
55a0e2
 		return -EX_DATAERR;
55a0e2
 	}
55a0e2
 
55a0e2
@@ -277,6 +283,7 @@ kfont_read_psffont(struct kfont_context
55a0e2
 
55a0e2
 	if (i > inputlth || (!hastable && i != inputlth)) {
55a0e2
 		KFONT_ERR(ctx, _("Input file: bad input length (%d)"), inputlth);
55a0e2
+		free(inputbuf);
55a0e2
 		return -EX_DATAERR;
55a0e2
 	}
55a0e2