From f78cd55ccd913855cc5569dfe2a9213e217bc469 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 15 Nov 2020 17:06:26 -0800 Subject: ucs2any: avoid segfaults if SLANT property is missing Test case: grep -v SLANT ../../misc-misc/5x7.bdf > 5x7-noslant.bdf ucs2any 5x7-noslant.bdf ../map-ISO8859-1 -d Before this fix, the above segfaults in strcmp with a NULL slant pointer. Fixes: 21063_131 from https://cyber-itl.org/2020/10/28/citl-7000-defects.html Signed-off-by: Alan Coopersmith --- ucs2any.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ucs2any.c b/ucs2any.c index 1f575d1..580b023 100644 --- a/ucs2any.c +++ b/ucs2any.c @@ -752,9 +752,11 @@ main(int argc, char *argv[]) da_add_int(map, target, ucs); } else { if (!((is_blockgraphics(ucs) && + slant != NULL && strcmp(slant, "R") != 0) || (ucs >= 0x200e && - ucs <= 0x200f))) { + ucs <= 0x200f))) + { fprintf(stderr, "No glyph for character U+%04X (0x%02x) available.\n", ucs, target); @@ -780,8 +782,9 @@ main(int argc, char *argv[]) } if (dec_chars == 1 || - (dec_chars == -1 && strcmp(slant, "R") == 0 && - strcmp(spacing, "C") == 0)) + (dec_chars == -1 && + (slant != NULL && strcmp(slant, "R") == 0) && + (spacing != NULL && strcmp(spacing, "C") == 0))) { /* add DEC VT100 graphics characters in the range 1-31 (as expected by some old xterm versions) */ -- cgit v1.2.3