git: 119db52f4228 - main - vtfontcvt: improve hex font format validation

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 19 Jul 2022 15:48:19 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=119db52f4228fae161306ac29dc739638c132c26

commit 119db52f4228fae161306ac29dc739638c132c26
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-07-19 15:20:10 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-07-19 15:48:09 +0000

    vtfontcvt: improve hex font format validation
    
    Previously an EOF would result in sscanf returning -1 leading to a
    crash.
    
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
---
 usr.bin/vtfontcvt/vtfontcvt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c
index 8effafcf16f2..eafe7209796f 100644
--- a/usr.bin/vtfontcvt/vtfontcvt.c
+++ b/usr.bin/vtfontcvt/vtfontcvt.c
@@ -565,7 +565,7 @@ parse_hex(FILE *fp, unsigned int map_idx)
 			if (bytes != NULL)
 				errx(1, "malformed input: Width tag after font data");
 			set_width(atoi(ln + 9));
-		} else if (sscanf(ln, "%6x:", &curchar)) {
+		} else if (sscanf(ln, "%6x:", &curchar) == 1) {
 			if (bytes == NULL) {
 				bytes = xmalloc(wbytes * height);
 				bytes_r = xmalloc(wbytes * height);