Skip to content

Commit

Permalink
Merge branch 'release-1.8' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Dec 30, 2019
2 parents 6e7c634 + d3be559 commit 4fa442b
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 9 deletions.
97 changes: 97 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
2019-12-28 Hayaki Saito <saitoha@me.com>

* src/encoder.c, src/loader.c, src/output.c, src/pixelformat.c: Strip
trailing spaces

* configure, configure.ac, package.json: Bump version

* ChangeLog, Makefile.in: Update ChangeLog

2019-12-27 Hayaki Saito <saitoha@me.com>

* Makefile.in, config.h.in, configure, configure.ac, src/loader.c: Avoid
Expand All @@ -15,6 +24,9 @@

2019-12-23 Hayaki Saito <saitoha@me.com>

* include/sixel.h.in, src/allocator.c: Introduce SIXEL_ALLOCATE_BYTES_MAX
macro and limit allocation size to 128MB(#74)

* src/fromgif.c: Minor fixes in load_gif().

* src/fromgif.c: GIF loader: check bad image separator, ensure left/top
Expand Down Expand Up @@ -123,6 +135,11 @@
* src/dither.c: Avoid illegal memory access problem with 1 color paletted
png(#73), Thanks to HongxuChen.

* Makefile.in, aclocal.m4, configure, converters/Makefile.in,
include/Makefile.in, m4/ax_gcc_builtin.m4, python/Makefile.in,
src/Makefile.in, tools/Makefile.in: Add missing m4 macro
m4/ax_gcc_builtin.m4

* README.md: Update README

* README.md: Update README
Expand Down Expand Up @@ -341,6 +358,8 @@
* src/decoder.c: Fix memory leak problems reported in #67
https://github.com/saitoha/libsixel/issues/67

* src/dither.c, src/encoder.c, src/quant.c: Add some comments

* src/dither.c, src/quant.c: Issue #68: check invalid color number(<1)
https://github.com/saitoha/libsixel/issues/68

Expand All @@ -350,8 +369,36 @@
* src/frompnm.c: Prevent stack-buffer-overflow reported in #71
https://github.com/saitoha/libsixel/issues/71

2018-06-25 Hayaki Saito <saitoha@me.com>

* src/stb_image.h: Prevent occurence of UndefinedBehaviorSanitizer in
stb_image

2018-06-19 Hayaki Saito <saitoha@me.com>

* Makefile.in, aclocal.m4, config.h.in, configure, configure.ac,
converters/Makefile.in, include/Makefile.in, python/Makefile.in,
src/Makefile.in, src/fromsixel.c, tools/Makefile.in: Add missing default
case in RGB to HLS converter

2018-06-18 Hayaki Saito <saitoha@me.com>

* README.md: Add ax_gcc_builtin.m4 for checking GCC built-in functions

2018-06-17 Hayaki Saito <saitoha@me.com>

* src/encoder.c, src/loader.c, src/output.c, src/pixelformat.c: Strip
trailing spaces

2018-06-14 Hayaki Saito <saitoha@me.com>

* examples/opengl/main.c: example/opengl: use high level API,
sixel_encoder_encode_bytes() instead of sixel_encode()

2018-06-10 Hayaki Saito <saitoha@me.com>

* converters/img2sixel.1: Fix a typo: a_dither -> x_dither(issue #66)

* Makefile.in, config.h.in, configure, configure.ac, package.json: Bump
version: 1.8.1

Expand Down Expand Up @@ -492,8 +539,55 @@
CODE IN LZW COMPRESSION" in [this
document](https://www.w3.org/Graphics/GIF/spec-gif89a.txt).

2018-03-17 Hayaki Saito <saitoha@me.com>

* Makefile.in, aclocal.m4, compile, config.guess, config.sub, configure,
converters/Makefile.in, depcomp, include/Makefile.in, install-sh, missing,
py-compile, python/Makefile.in, src/Makefile.in, tools/Makefile.in: Update
autotools version

2017-06-22 Hayaki Saito <saitoha@me.com>

* src/fromsixel.c: Fix wrong HLS color handling

2017-06-23 Hayaki Saito <saitoha@me.com>

* LICENSE.xterm, src/fromsixel.c: Rewrinte HLS handling function
hls_to_rgb()

* include/sixel.h.in, src/dither.c, src/dither.h, src/quant.c, src/quant.h,
src/tosixel.c: Introduce new meta type sixel_index_t (now equals unsigned
char)

* src/output.h, src/tosixel.c: sixel_node_t::map should be represented as
7bit character, not 8bit

* src/encoder.c, src/quant.c: Add annotations for some fixed buffer size

* src/dither.c, src/encoder.c, src/quant.c, src/tosixel.c: Respect to
constant value SIXEL_PALETTE_MAX

* src/tosixel.c: Prevent HLS saturation parameter overflow(>100)

2017-06-22 Hayaki Saito <saitoha@me.com>

* src/fromsixel.c: Fix wrong HLS color handling

2017-06-10 Hayaki Saito <saitoha@me.com>

* README.md: Update README for adding some language bindings

* examples/drawing/main.c, examples/opengl/main.c, src/output.c: Example:
Minor fixes

2017-06-03 Hayaki Saito <saitoha@me.com>

* examples/opengl/main.c: demo/opengl: don't use deplecated API functions

2017-05-18 Hayaki Saito <saitoha@me.com>

* README.md: README: add mention for forth-sixel

* converters/Makefile.am, converters/Makefile.in: Minor fixes

2017-05-03 Hayaki Saito <saitoha@me.com>
Expand All @@ -506,6 +600,9 @@

* converters/img2sixel.c: Fix typo a_dither -> x_dither

* README.md, converters/img2sixel.1, converters/img2sixel.c: Mark -D,
--pipe-mode option as deprecated.

* .travis.yml: Reduce test cases for OSX.

* src/encoder.c: Fix for Issue #57, lack of O_TRUNC when open() is called.
Expand Down
5 changes: 2 additions & 3 deletions include/sixel.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ typedef unsigned char sixel_index_t;
#define SIXEL_PALETTE_MAX 256
#define SIXEL_USE_DEPRECATED_SYMBOLS 1
#define SIXEL_ALLOCATE_BYTES_MAX 10248UL * 1024UL * 128UL /* up to 128M */
#define SIXEL_WIDTH_LIMIT 1000000
#define SIXEL_HEIGHT_LIMIT 1000000

/* return value */
typedef int SIXELSTATUS;
Expand Down Expand Up @@ -370,9 +372,6 @@ typedef int SIXELSTATUS;
#define SIXEL_OPTFLAG_VERSION ('V') /* -V, --version: show version and license info */
#define SIXEL_OPTFLAG_HELP ('H') /* -H, --help: show this help */

#define SIXEL_WIDTH_LIMIT 1000000
#define SIXEL_HEIGHT_LIMIT 1000000

#define SIXEL_DEFALUT_GIF_DELAY 1

#if SIXEL_USE_DEPRECATED_SYMBOLS
Expand Down
8 changes: 4 additions & 4 deletions src/frompnm.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ load_pnm(unsigned char /* in */ *p,
unsigned char *s;
unsigned char *end;
unsigned char tmp[256];
size_t size;

(void) ppalette;
(void) pncolors;
Expand Down Expand Up @@ -210,9 +211,8 @@ load_pnm(unsigned char /* in */ *p,
goto invalid;
}

*result = (unsigned char *)sixel_allocator_malloc(
allocator,
(size_t)(width * height * 3 + 1));
size = (size_t)width * (size_t)height * 3 + 1;
*result = (unsigned char *)sixel_allocator_malloc(allocator, size);

if (*result == NULL) {
sixel_helper_set_additional_message(
Expand All @@ -221,7 +221,7 @@ load_pnm(unsigned char /* in */ *p,
goto end;
}

memset(*result, 0, (size_t)(width * height * 3 + 1));
(void) memset(*result, 0, size);

for (y = 0 ; y < height ; y++) {
for (x = 0 ; x < width ; x++) {
Expand Down
21 changes: 19 additions & 2 deletions src/tosixel.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ sixel_encode_dither(
case SIXEL_PIXELFORMAT_G1:
case SIXEL_PIXELFORMAT_G2:
case SIXEL_PIXELFORMAT_G4:
bufsize = (sizeof(sixel_index_t) * (size_t)(width * height * 3));
bufsize = (sizeof(sixel_index_t) * (size_t)width * (size_t)height * 3UL);
paletted_pixels = (sixel_index_t *)sixel_allocator_malloc(dither->allocator, bufsize);
if (paletted_pixels == NULL) {
sixel_helper_set_additional_message(
Expand Down Expand Up @@ -1516,11 +1516,27 @@ sixel_encode(
{
SIXELSTATUS status = SIXEL_FALSE;

(void) depth;

/* TODO: reference counting should be thread-safe */
sixel_dither_ref(dither);
sixel_output_ref(output);

(void) depth;
if (width < 1) {
sixel_helper_set_additional_message(
"sixel_encode: bad width parameter."
" (width < 1)");
status = SIXEL_BAD_INPUT;
goto end;
}

if (height < 1) {
sixel_helper_set_additional_message(
"sixel_encode: bad height parameter."
" (height < 1)");
status = SIXEL_BAD_INPUT;
goto end;
}

if (dither->quality_mode == SIXEL_QUALITY_HIGHCOLOR) {
status = sixel_encode_highcolor(pixels, width, height,
Expand All @@ -1530,6 +1546,7 @@ sixel_encode(
dither, output);
}

end:
sixel_output_unref(output);
sixel_dither_unref(dither);

Expand Down
40 changes: 40 additions & 0 deletions src/writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,46 @@ sixel_helper_write_image_file(
sixel_allocator_ref(allocator);
}

if (width > SIXEL_WIDTH_LIMIT) {
sixel_helper_set_additional_message(
"sixel_encode: bad width parameter."
" (width > SIXEL_WIDTH_LIMIT)");
status = SIXEL_BAD_INPUT;
goto end;
}

if (width > SIXEL_HEIGHT_LIMIT) {
sixel_helper_set_additional_message(
"sixel_encode: bad width parameter."
" (width > SIXEL_HEIGHT_LIMIT)");
status = SIXEL_BAD_INPUT;
goto end;
}

if (height < 1) {
sixel_helper_set_additional_message(
"sixel_encode: bad height parameter."
" (height < 1)");
status = SIXEL_BAD_INPUT;
goto end;
}

if (width < 1) {
sixel_helper_set_additional_message(
"sixel_encode: bad width parameter."
" (width < 1)");
status = SIXEL_BAD_INPUT;
goto end;
}

if (height < 1) {
sixel_helper_set_additional_message(
"sixel_encode: bad height parameter."
" (height < 1)");
status = SIXEL_BAD_INPUT;
goto end;
}

switch (imageformat) {
case SIXEL_FORMAT_PNG:
status = write_png_to_file(data, width, height, palette,
Expand Down

0 comments on commit 4fa442b

Please sign in to comment.