Skip to content

Commit 07ab235

Browse files
committed
Fixed the FPE issue reported in #166 and #167
1 parent f2e21ef commit 07ab235

File tree

6 files changed

+50
-6
lines changed

6 files changed

+50
-6
lines changed

Makefile.am

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ issue-165:
9090
issue-165-vexe:
9191
tools/vexe --without-png ubuntu issue-165
9292

93+
issue-166:
94+
converters/img2sixel ../tests/issue/166/poc -w128 ; test $$? = 255 -o $$? = 127
95+
96+
issue-166-vexe:
97+
tools/vexe --platform=amd64 ubuntu issue-166
98+
99+
issue-167:
100+
converters/img2sixel ../tests/issue/167/poc -h128 ; test $$? = 255 -o $$? = 127
101+
102+
issue-167-vexe:
103+
tools/vexe --platform=amd64 ubuntu issue-167
104+
93105
libsixel-libsixel-issue-73:
94106
converters/img2sixel tests/issue/libsixel-libsixel/73/stbi_1561_poc.bin
95107

Makefile.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,18 @@ issue-165:
10071007
issue-165-vexe:
10081008
tools/vexe --without-png ubuntu issue-165
10091009

1010+
issue-166:
1011+
converters/img2sixel ../tests/issue/166/poc -w128 ; test $$? = 255 -o $$? = 127
1012+
1013+
issue-166-vexe:
1014+
tools/vexe --platform=amd64 ubuntu issue-166
1015+
1016+
issue-167:
1017+
converters/img2sixel ../tests/issue/167/poc -h128 ; test $$? = 255 -o $$? = 127
1018+
1019+
issue-167-vexe:
1020+
tools/vexe --platform=amd64 ubuntu issue-167
1021+
10101022
libsixel-libsixel-issue-73:
10111023
converters/img2sixel tests/issue/libsixel-libsixel/73/stbi_1561_poc.bin
10121024

converters/Makefile.am

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ if WANT_IMG2SIXEL
8989
test ! $$($(WINE) $(builddir)/img2sixel$(WINEEXT) -I -p8 $(top_srcdir)/images/snake.png)
9090
test ! $$($(WINE) $(builddir)/img2sixel$(WINEEXT) -p64 -bxterm256 $(top_srcdir)/images/snake.png)
9191
test ! $$($(WINE) $(builddir)/img2sixel$(WINEEXT) -8 -P $(top_srcdir)/images/snake.png)
92-
$(WINE) $(builddir)/img2sixel$(WINEEXT) -B "#000" -B ""; test $$? = 255 -o $$? = 127
9392

9493
@echo '[test2] STDIN handling'
9594
test ! $$(echo -n a | $(WINE) $(builddir)/img2sixel$(WINEEXT))
@@ -273,8 +272,12 @@ if WANT_SIXEL2PNG
273272
$(WINE) $(builddir)/sixel2png$(WINEEXT) - - < $(builddir)/tmp/snake3.sixel > $(builddir)/tmp/snake3.png
274273
$(WINE) $(builddir)/sixel2png$(WINEEXT) -i $(builddir)/tmp/snake.sixel -o $(builddir)/tmp/snake4.png
275274
endif
275+
@echo '[test13] regression test'
276+
$(WINE) $(builddir)/img2sixel$(WINEEXT) -B "#000" -B ""; test $$? = 255 -o $$? = 127
277+
$(WINE) $(builddir)/img2sixel$(WINEEXT) ../tests/issue/167/poc -h128 ; test $$? = 255 -o $$? = 127
278+
$(WINE) $(builddir)/img2sixel$(WINEEXT) ../tests/issue/166/poc -w128 ; test $$? = 255 -o $$? = 127
276279

277-
@echo '[test13] documentation'
280+
@echo '[test14] documentation'
278281
$(WINE) $(builddir)/img2sixel$(WINEEXT) -H| grep ^\ \*\-|sed 's/^\ *//'| cut -f1 -d' '| cut -f1 -d, > $(builddir)/tmp/options1.txt
279282
grep ^\.B $(srcdir)/img2sixel.1 | cut -f2 -d " " | grep "^\\\\" | tr -d '\\' | tr -d , > $(builddir)/tmp/options2.txt
280283
grep ' --' $(srcdir)/shell-completion/bash/img2sixel| grep -v "' "| sed 's/.* \(-.\) .*/\1/' > $(builddir)/tmp/options3.txt

converters/Makefile.in

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,6 @@ test_impl:
10791079
@WANT_IMG2SIXEL_TRUE@ test ! $$($(WINE) $(builddir)/img2sixel$(WINEEXT) -I -p8 $(top_srcdir)/images/snake.png)
10801080
@WANT_IMG2SIXEL_TRUE@ test ! $$($(WINE) $(builddir)/img2sixel$(WINEEXT) -p64 -bxterm256 $(top_srcdir)/images/snake.png)
10811081
@WANT_IMG2SIXEL_TRUE@ test ! $$($(WINE) $(builddir)/img2sixel$(WINEEXT) -8 -P $(top_srcdir)/images/snake.png)
1082-
@WANT_IMG2SIXEL_TRUE@ $(WINE) $(builddir)/img2sixel$(WINEEXT) -B "#000" -B ""; test $$? = 255 -o $$? = 127
10831082

10841083
@WANT_IMG2SIXEL_TRUE@ @echo '[test2] STDIN handling'
10851084
@WANT_IMG2SIXEL_TRUE@ test ! $$(echo -n a | $(WINE) $(builddir)/img2sixel$(WINEEXT))
@@ -1257,8 +1256,12 @@ test_impl:
12571256
@WANT_IMG2SIXEL_TRUE@@WANT_SIXEL2PNG_TRUE@ $(WINE) $(builddir)/sixel2png$(WINEEXT) < $(builddir)/tmp/snake2.sixel > $(builddir)/tmp/snake2.png
12581257
@WANT_IMG2SIXEL_TRUE@@WANT_SIXEL2PNG_TRUE@ $(WINE) $(builddir)/sixel2png$(WINEEXT) - - < $(builddir)/tmp/snake3.sixel > $(builddir)/tmp/snake3.png
12591258
@WANT_IMG2SIXEL_TRUE@@WANT_SIXEL2PNG_TRUE@ $(WINE) $(builddir)/sixel2png$(WINEEXT) -i $(builddir)/tmp/snake.sixel -o $(builddir)/tmp/snake4.png
1259+
@WANT_IMG2SIXEL_TRUE@ @echo '[test13] regression test'
1260+
@WANT_IMG2SIXEL_TRUE@ $(WINE) $(builddir)/img2sixel$(WINEEXT) -B "#000" -B ""; test $$? = 255 -o $$? = 127
1261+
@WANT_IMG2SIXEL_TRUE@ $(WINE) $(builddir)/img2sixel$(WINEEXT) ../tests/issue/167/poc -h128 ; test $$? = 255 -o $$? = 127
1262+
@WANT_IMG2SIXEL_TRUE@ $(WINE) $(builddir)/img2sixel$(WINEEXT) ../tests/issue/166/poc -w128 ; test $$? = 255 -o $$? = 127
12601263

1261-
@WANT_IMG2SIXEL_TRUE@ @echo '[test13] documentation'
1264+
@WANT_IMG2SIXEL_TRUE@ @echo '[test14] documentation'
12621265
@WANT_IMG2SIXEL_TRUE@ $(WINE) $(builddir)/img2sixel$(WINEEXT) -H| grep ^\ \*\-|sed 's/^\ *//'| cut -f1 -d' '| cut -f1 -d, > $(builddir)/tmp/options1.txt
12631266
@WANT_IMG2SIXEL_TRUE@ grep ^\.B $(srcdir)/img2sixel.1 | cut -f2 -d " " | grep "^\\\\" | tr -d '\\' | tr -d , > $(builddir)/tmp/options2.txt
12641267
@WANT_IMG2SIXEL_TRUE@ grep ' --' $(srcdir)/shell-completion/bash/img2sixel| grep -v "' "| sed 's/.* \(-.\) .*/\1/' > $(builddir)/tmp/options3.txt

src/encoder.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,20 @@ sixel_encoder_do_resize(
621621
src_width = sixel_frame_get_width(frame);
622622
src_height = sixel_frame_get_height(frame);
623623

624+
if (src_width < 1) {
625+
sixel_helper_set_additional_message(
626+
"sixel_encoder_do_resize: "
627+
"detected a frame with a non-positive width.");
628+
return SIXEL_BAD_ARGUMENT;
629+
}
630+
631+
if (src_height < 1) {
632+
sixel_helper_set_additional_message(
633+
"sixel_encoder_do_resize: "
634+
"detected a frame with a non-positive height.");
635+
return SIXEL_BAD_ARGUMENT;
636+
}
637+
624638
/* settings around scaling */
625639
dst_width = encoder->pixelwidth; /* may be -1 (default) */
626640
dst_height = encoder->pixelheight; /* may be -1 (default) */

tools/vexe

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ while getopts h-: opt; do
4343
pp__force_disable_src_cache=1
4444
;;
4545
-p|--platform)
46-
opt__platform="${optarg}"
46+
opt__platform="${optarg#=}"
4747
;;
4848
--require-valgrind)
4949
pp__valgrind=1
@@ -96,7 +96,7 @@ cd "$(git rev-parse --show-toplevel || dirname "${0}")" && {
9696

9797
# make distclean || :
9898

99-
: "${dockeropt__platform:="${opt__platform:+linux/"${opt__platform}"}"}"
99+
: "${dockeropt__platform:="--platform ${opt__platform:+linux/"${opt__platform}"}"}"
100100

101101
# workaround: We cannot find multi-arch slackware...
102102
: "${pp__os_slackware+:+"${dockeropt__platform:="--platform linux/amd64"}"}"

0 commit comments

Comments
 (0)