From 594da76b5f77e2214d2f7641308463055461b095 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Fix some non-exploitable buffer overflows in mkbootmsg (LP: #27011). Gbp-Pq: Name 0001-asprintf.patch --- gfxboot-compile.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/gfxboot-compile.c b/gfxboot-compile.c index dd882e8..835450e 100644 --- a/gfxboot-compile.c +++ b/gfxboot-compile.c @@ -1763,7 +1763,7 @@ void log_cline(FILE *lf) } -char *add_to_line(char *s) +char *add_to_line(const char *s) { static char buf[10240] = {}; static int ind = 0; @@ -1812,7 +1812,7 @@ void decompile(unsigned char *data, unsigned size) unsigned inst_size; dict_t *d; unsigned type; - char *s, buf[1024]; + char *s, *buf; unsigned char *p; // setup initial vocabulary @@ -1889,13 +1889,15 @@ void decompile(unsigned char *data, unsigned size) } case t_unsigned: - sprintf(buf, "%d", val); + asprintf(&buf, "%d", val); add_to_line(buf); + free(buf); break; case t_string: + buf = malloc(strlen((char *) data + i + u + 1) * 4 + 3); buf[0] = '"'; - for(j = 1, p = data + i + u + 1; *p && j < sizeof buf - 10; p++) { + for(j = 1, p = data + i + u + 1; *p; p++) { if(*p == '\n') { buf[j++] = '\\'; buf[j++] = 'n'; @@ -1917,16 +1919,18 @@ void decompile(unsigned char *data, unsigned size) buf[j++] = '"'; buf[j] = 0; s = add_to_line(buf); + free(buf); break; case t_sec: if(val < dict_size && dict[val].name) { - sprintf(buf, "%s", dict[val].name); + asprintf(&buf, "%s", dict[val].name); } else { - sprintf(buf, "name_%d", val); + asprintf(&buf, "name_%d", val); } s = add_to_line(buf); + free(buf); printf("%s\n", s); add_to_line(""); break; @@ -1939,38 +1943,42 @@ void decompile(unsigned char *data, unsigned size) } } if(s) { - sprintf(buf, "%s", s); + asprintf(&buf, "%s", s); } else { - sprintf(buf, "prim_<%d>", val); + asprintf(&buf, "prim_<%d>", val); } s = add_to_line(buf); + free(buf); printf("%s\n", s); add_to_line(""); break; case t_bool: - sprintf(buf, "%s", val ? "true" : "false"); + asprintf(&buf, "%s", val ? "true" : "false"); s = add_to_line(buf); + free(buf); printf("%s\n", s); add_to_line(""); break; case t_none: - sprintf(buf, ".undef"); + asprintf(&buf, ".undef"); s = add_to_line(buf); + free(buf); printf("%s\n", s); add_to_line(""); break; case t_dict_idx: if(val < dict_size && dict[val].name) { - sprintf(buf, "/%s", dict[val].name); + asprintf(&buf, "/%s", dict[val].name); } else { - sprintf(buf, "/name_%d", val); + asprintf(&buf, "/name_%d", val); } add_to_line(buf); + free(buf); break; default: -- cgit v1.2.3 From 3a9928081a5c27c91f2eaea68a257034a62a6488 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Make sure to pass unsigned chars to isspace(), per the C standard; not doing so can cause problems on powerpc and other architectures. Gbp-Pq: Name 0002-ctype.patch --- gfxboot-compile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfxboot-compile.c b/gfxboot-compile.c index 835450e..0914d53 100644 --- a/gfxboot-compile.c +++ b/gfxboot-compile.c @@ -658,7 +658,7 @@ char *next_word(char **ptr) *word = 0; - while(isspace(*s)) if(*s++ == '\n') line++; + while(isspace((unsigned char) *s)) if(*s++ == '\n') line++; if(!*s) { *ptr = s; @@ -757,7 +757,7 @@ char *next_word(char **ptr) word[n] = 0; } else { - while(!isspace(*s)) s++; + while(!isspace((unsigned char) *s)) s++; } if(!is_str) { -- cgit v1.2.3 From 39e66f0c84b7db320bbf701b0100a4542ebf04c0 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Try .bdf files in gfxboot-font. Gbp-Pq: Name 0003-bdf.patch --- gfxboot-font.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfxboot-font.c b/gfxboot-font.c index 994d07b..db2629d 100644 --- a/gfxboot-font.c +++ b/gfxboot-font.c @@ -920,7 +920,7 @@ char *search_font(char *font_path, char *name) char *font_name = NULL; char *cur_path, *sep; struct stat sbuf; - static char *suffix[] = { "", ".ttf", ".pfa", ".pfb", ".pcf.gz" }; + static char *suffix[] = { "", ".ttf", ".pfa", ".pfb", ".pcf.gz", ".bdf" }; if(!font_path || !name) return NULL; -- cgit v1.2.3 From 0cf5dafd96c2f93189d4cbef5ede4cc1addb399d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Fix link order with 'ld --as-needed' (Closes: #605771). Gbp-Pq: Name 0004-link-order.patch --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 97b60d7..c0ed84c 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ changelog: $(GITDEPS) $(GIT2LOG) --changelog changelog gfxboot-font: gfxboot-font.c - $(CC) $(CFLAGS) -I /usr/include/freetype2 -lfreetype $< -o $@ + $(CC) $(CFLAGS) -I /usr/include/freetype2 $< -lfreetype -o $@ gfxboot-compile: gfxboot-compile.c vocabulary.h bincode.h $(CC) $(CFLAGS) $< -o $@ -- cgit v1.2.3 From d4ab42cb33a6fb098048dd07a69f79ba071d5421 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Avoid overwriting buildflags. Gbp-Pq: Name 0005-buildflags.patch --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c0ed84c..dc6ff85 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC = gcc -CFLAGS = -g -Wall -Wno-pointer-sign -O2 -fomit-frame-pointer +#CFLAGS = -g -Wall -Wno-pointer-sign -O2 -fomit-frame-pointer GIT2LOG := $(shell if [ -x ./git2log ] ; then echo ./git2log --update ; else echo true ; fi) GITDEPS := $(shell [ -d .git ] && echo .git/HEAD .git/refs/heads .git/refs/tags) -- cgit v1.2.3 From 70bf4dd665d31475a8e9be0849a618df87168ed5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Updating syslinux paths (Closes: #682974). Gbp-Pq: Name 0006-syslinux-path.patch --- gfxboot | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gfxboot b/gfxboot index 538bf8d..f7cda36 100755 --- a/gfxboot +++ b/gfxboot @@ -989,9 +989,9 @@ my @vm_order = qw ( qemu64 qemu32 qemu qemu-kvm vbox vbox64 vboxsdl vmplayer vmw my %bl_list = ( grub => '/usr/sbin/grub', lilo => '/sbin/lilo', - isolinux => '/usr/share/syslinux/isolinux.bin', + isolinux => '/usr/lib/syslinux/isolinux.bin', syslinux => '/usr/bin/syslinux', - pxelinux => '/usr/share/syslinux/pxelinux.0', + pxelinux => '/usr/lib/syslinux/pxelinux.0', bd => '/usr/bin/bd', bochs => '/usr/bin/bochs', ); @@ -1793,8 +1793,8 @@ sub prepare_isolinux $arch_dir = 'i386'; $arch_dir = 'x86_64' if $opt_64 && !$opt_32; - $comboot = "$opt_syslinux/usr/share/syslinux/gfxboot.c32"; - $comboot = "$opt_syslinux/usr/share/syslinux/gfxboot.com" unless -f $comboot; + $comboot = "$opt_syslinux/usr/lib/syslinux/gfxboot.c32"; + $comboot = "$opt_syslinux/usr/lib/syslinux/gfxboot.com" unless -f $comboot; $comboot = 0 unless -f $comboot; my $menu = fake_menu 'install'; @@ -1864,7 +1864,7 @@ sub prepare_isolinux close F; } - system "cp $opt_syslinux/usr/share/syslinux/isolinux.bin $dst/$loader" and die "error: no isolinux\n"; + system "cp $opt_syslinux/usr/lib/syslinux/isolinux.bin $dst/$loader" and die "error: no isolinux\n"; system "cp $comboot $dst/$loader" if $comboot; for (@opt_test_addfiles) { @@ -1908,8 +1908,8 @@ sub prepare_syslinux die "error: syslinux not found\n" unless -f "$opt_syslinux/$bl_list{syslinux}"; - $comboot = "$opt_syslinux/usr/share/syslinux/gfxboot.c32"; - $comboot = "$opt_syslinux/usr/share/syslinux/gfxboot.com" unless -f $comboot; + $comboot = "$opt_syslinux/usr/lib/syslinux/gfxboot.c32"; + $comboot = "$opt_syslinux/usr/lib/syslinux/gfxboot.com" unless -f $comboot; $comboot = 0 unless -f $comboot; my $menu = fake_menu 'install'; @@ -2022,8 +2022,8 @@ sub prepare_pxelinux $arch_dir = 'i386'; $arch_dir = 'x86_64' if $opt_64 && !$opt_32; - $comboot = "$opt_syslinux/usr/share/syslinux/gfxboot.c32"; - $comboot = "$opt_syslinux/usr/share/syslinux/gfxboot.com" unless -f $comboot; + $comboot = "$opt_syslinux/usr/lib/syslinux/gfxboot.c32"; + $comboot = "$opt_syslinux/usr/lib/syslinux/gfxboot.com" unless -f $comboot; $comboot = 0 unless -f $comboot; my $menu = fake_menu 'install'; @@ -2093,7 +2093,7 @@ sub prepare_pxelinux close F; } - system "cp $opt_syslinux/usr/share/syslinux/pxelinux.0 $dst/$loader" and die "error: no pxelinux\n"; + system "cp $opt_syslinux/usr/lib/syslinux/pxelinux.0 $dst/$loader" and die "error: no pxelinux\n"; system "cp $comboot $dst/$loader" if $comboot; for (@opt_test_addfiles) { -- cgit v1.2.3 From 5a6d4627f1e0edf5b58297e28af58fb8d02ba4db Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: gfxboot expects fonts to be in /usr/share/fonts/truetype et al, not in subdirectories within like debian based systems do. The proper fix is to make search_font() in gfxboot-font recursive, however, for the time being we add the paths manually here. Gbp-Pq: Name 0007-ttf-dejavu.patch --- themes/example_02/Makefile | 2 +- themes/example_03/Makefile | 2 +- themes/example_04/Makefile | 2 +- themes/example_05/Makefile | 2 +- themes/example_06/Makefile | 2 +- themes/example_07/Makefile | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/themes/example_02/Makefile b/themes/example_02/Makefile index 0fb4640..c0d551d 100644 --- a/themes/example_02/Makefile +++ b/themes/example_02/Makefile @@ -16,7 +16,7 @@ bootlogo: example_*.bc font $(GFXBOOT) --archive $@.dir --pack-archive $@ font: - $(GFXBOOT_FONT) -v -f DejaVuSans:size=20 font.fnt >font.log + $(GFXBOOT_FONT) -v -p /usr/share/fonts/truetype/ttf-dejavu -f DejaVuSans:size=20 font.fnt >font.log clean: rm -rf *~ *.log *.dir bootlogo *.fnt diff --git a/themes/example_03/Makefile b/themes/example_03/Makefile index cffce2e..4e18e35 100644 --- a/themes/example_03/Makefile +++ b/themes/example_03/Makefile @@ -16,7 +16,7 @@ bootlogo: example_*.bc font $(GFXBOOT) --archive $@.dir --pack-archive $@ font: - $(GFXBOOT_FONT) -v -f DejaVuSans:size=20 font.fnt >font.log + $(GFXBOOT_FONT) -v -p /usr/share/fonts/truetype/ttf-dejavu -f DejaVuSans:size=20 font.fnt >font.log clean: rm -rf *~ *.log *.dir bootlogo *.fnt diff --git a/themes/example_04/Makefile b/themes/example_04/Makefile index 07357a5..e54c817 100644 --- a/themes/example_04/Makefile +++ b/themes/example_04/Makefile @@ -16,7 +16,7 @@ bootlogo: example_*.bc font $(GFXBOOT) --archive $@.dir --pack-archive $@ font: - $(GFXBOOT_FONT) -v -f DejaVuSans:size=32 font.fnt >font.log + $(GFXBOOT_FONT) -v -p /usr/share/fonts/truetype/ttf-dejavu -f DejaVuSans:size=32 font.fnt >font.log clean: rm -rf *~ *.log *.dir bootlogo *.fnt diff --git a/themes/example_05/Makefile b/themes/example_05/Makefile index 07357a5..e54c817 100644 --- a/themes/example_05/Makefile +++ b/themes/example_05/Makefile @@ -16,7 +16,7 @@ bootlogo: example_*.bc font $(GFXBOOT) --archive $@.dir --pack-archive $@ font: - $(GFXBOOT_FONT) -v -f DejaVuSans:size=32 font.fnt >font.log + $(GFXBOOT_FONT) -v -p /usr/share/fonts/truetype/ttf-dejavu -f DejaVuSans:size=32 font.fnt >font.log clean: rm -rf *~ *.log *.dir bootlogo *.fnt diff --git a/themes/example_06/Makefile b/themes/example_06/Makefile index bf21c5d..0a3c7cd 100644 --- a/themes/example_06/Makefile +++ b/themes/example_06/Makefile @@ -20,7 +20,7 @@ bootlogo: example_*.bc font @ln -snf bootlogo message font: - $(GFXBOOT_FONT) -v -f DejaVuSans:size=32 font.fnt >font.log + $(GFXBOOT_FONT) -v -p /usr/share/fonts/truetype/ttf-dejavu -f DejaVuSans:size=32 font.fnt >font.log clean: rm -rf *~ *.log *.dir bootlogo message *.fnt diff --git a/themes/example_07/Makefile b/themes/example_07/Makefile index bf21c5d..0a3c7cd 100644 --- a/themes/example_07/Makefile +++ b/themes/example_07/Makefile @@ -20,7 +20,7 @@ bootlogo: example_*.bc font @ln -snf bootlogo message font: - $(GFXBOOT_FONT) -v -f DejaVuSans:size=32 font.fnt >font.log + $(GFXBOOT_FONT) -v -p /usr/share/fonts/truetype/ttf-dejavu -f DejaVuSans:size=32 font.fnt >font.log clean: rm -rf *~ *.log *.dir bootlogo message *.fnt -- cgit v1.2.3 From 28cd16fa4fc0ebfc02c30ef3a9fe615245675988 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 3 Jan 2021 02:06:39 -0800 Subject: Replacing adddir location with absolute name in order to allow to compile the themes from any location, not just /usr/share/gfxboot/themes/foo. Gbp-Pq: Name 0008-adddir.patch --- themes/openSUSE/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/openSUSE/Makefile b/themes/openSUSE/Makefile index 9372629..3a71f9b 100644 --- a/themes/openSUSE/Makefile +++ b/themes/openSUSE/Makefile @@ -10,7 +10,7 @@ else PREPARED = $(shell [ -f .prepared ] && echo 1) endif -ADDDIR = ../../bin/adddir +ADDDIR ?= /usr/share/gfxboot/bin/adddir BFLAGS = -O -v -L ../.. SUBDIRS = fonts help-boot help-install po src -- cgit v1.2.3