Commit Graph

37 Commits (master)

Author SHA1 Message Date
Tim Gates f7e57be725 docs: Fix a few typos
There are small typos in:
- examples/copyrotated.c
- src/gd.c
- src/gd.h
- src/gd_avif.c
- src/gd_nnquant.c
- src/gd_tga.c
- src/gd_topal.c
- src/wbmp.c
- tests/avif/compare_avif_to_png.c

Fixes:
- Should read `requires` rather than `reqiures`.
- Should read `of the` rather than `ofthe`.
- Should read `memory` rather than `memmory`.
- Should read `maximum` rather than `maxmum`.
- Should read `intersection` rather than `intertersection`.
- Should read `hypotenuse` rather than `hypothenus`.
- Should read `flexibility` rather than `flexibilty`.
- Should read `always` rather than `alwasy`.
- Should read `also` rather than `alos`.
2021-09-23 01:13:40 -04:00
maryam ebrahimzadeh 8b111b2b4a fix read out-of-bands in reading tga header file 2021-07-19 10:07:13 +04:30
Mike Frysinger b402909c42 tga: delay calculation to avoid undefined behavior
oss-fuzz pointed out:
gd_tga.c:209:52: runtime error: signed integer overflow: 838848000 * 3 cannot be represented in type 'int'

This is somewhat of a false positive as we already have overflow checks
after this assignment, but we can delay the code until afterwards to
avoid warnings.
2018-01-26 02:13:26 -05:00
Christoph M. Becker 58b6dde319 Fix OOB reads of the TGA decompression buffer
It is possible to craft TGA files which will overflow the decompression
buffer, but not the image's bitmap. Therefore we also have to check for
potential decompression buffer overflows.

This issue had been reported by Ibrahim El-Sayed to security@libgd.org;
a modified case exposing an off-by-one error of the first patch had been
provided by Konrad Beckmann.

This commit is an amendment to commit fb0e0cce, so we use CVE-2016-6906
as well.
2016-12-13 15:51:51 +01:00
Christoph M. Becker fb0e0cce0b Fix OOB reads of the TGA decompression buffer
It is possible to craft TGA files which will overflow the decompression
buffer, but not the image's bitmap. Therefore we augment the check for the
bitmap's overflow with a check for the buffer's overflow.

This issue had been reported by Ibrahim El-Sayed to security@libgd.org.

CVE-2016-6906
2016-12-13 13:31:05 +01:00
Christoph M. Becker 4f8e26f2a4 Fix #290: TGA RLE decoding is broken
We make it work only, for now. Actually, it doesn't make sense that
`oTga::bitmap` is an `int *` as we're storing only bytes there. If this
will be changed, we can even get rid of the `conversion_buffer` in
`read_image_tga` altogether, and read the image data into the
`decompression_buffer` (if RLE'd) or the `tga->bitmap` (if uncompressed)
directly.
2016-08-16 14:27:23 +02:00
Christoph M. Becker 9a3bd7077e Group the supported image formats in the menu of the docs
To do so we have to add Menu.txt to the project, but we can ignore
Languages.txt and Topics.txt, at least for now.
2016-08-14 16:11:05 +02:00
Christoph M. Becker b0333689ef Document all BGD_DECLARE'd functions
We add only minimal documentation comments for now, but at least that lets
Natural Docs add the function prototypes to the documentation.
2016-07-20 21:24:48 +02:00
Christoph M. Becker 71f2ff370e Fix #264: TGA warning coverity
We fix the unintended sign extension issue #150385 by declaring encoded_pixels
as int, and the logical vs. bitwise operator issue #150382 by using the
proper operator.
2016-07-19 11:41:46 +02:00
Ondřej Surý ff0234f4da Proper fix for #248 2016-07-15 09:43:45 +02:00
Ondřej Surý 981060efd6 bug #248, fix Out-Of-Bounds Read in read_image_tga 2016-07-14 10:39:41 +02:00
Christoph M. Becker cb1a0b7e54 Unsupported TGA bpp/alphabit combinations should error gracefully
Currently, only 24bpp without alphabits and 32bpp with 8 alphabits are
really supported. All other combinations will be rejected with a warning.
2016-07-13 00:43:10 +02:00
Christoph M. Becker 076e0d19d7 Revert "Unsupported TGA bpp/alphabit combinations should error gracefully"
This reverts commit 10ef1dca63.

There are build errors, so we revert for now.
2016-07-12 22:09:13 +02:00
Christoph M. Becker 10ef1dca63 Unsupported TGA bpp/alphabit combinations should error gracefully
Currently, only 24bpp without alphabits and 32bpp with 8 alphabits are
really supported. All other combinations will be rejected with a warning.
2016-07-12 20:46:33 +02:00
Ondřej Surý ead349e998 Fix #247, A read out-of-bands was found in the parsing of TGA files (CVE-2016-6132) 2016-07-12 16:11:51 +02:00
Mike Frysinger 2733b623ee tga: cleanup/simplify a bit
Try to standardize the internals a little bit and simplify the read
paths to abort early on when we know we won't actually handle the
input format.  Avoid resetting pointers that are on the stack or we
release as it's a waste of code.
2016-05-14 03:51:26 -04:00
Mike Frysinger 96d5687689 tga: fix two memory corruption bugs #159
First, if the tga input had an ID set, we'd read this into the pointer
itself (and the memory after it in the struct/heap) instead of the memory
allocated to hold it.  This bug has been around since the tga code was
first added.  We'd basically corrupt memory all the time since most tga
files out there have an ID set up (like a datestamp).

Second, make sure we reject invalid images that would cause overflows in
the allocation path.  We tried to check for this already, but we used the
wrong type (we checked uint8_t but allocated int).

Fixes #159.
2016-05-14 03:45:42 -04:00
Pierre Joye acdebc8148 fix #84, double free and overrun due to wrong alloc type, uint8_t instead of int 2015-01-19 05:40:53 +01:00
Ondřej Surý 9336856638 Use standard int types in gd_tga.* instead of using 'byte' defined as int 2013-05-02 09:31:15 +02:00
Takeshi Abe 8843ac583a avoid warning: implicit declaration of function ‘gd_error’ [-Wimplicit-function-declaration] 2013-04-20 08:18:20 +09:00
Ondřej Surý 32b1307c62 Use custom error handler instead of fprintf(stderr, ...) 2013-04-18 08:28:36 +02:00
Ondřej Surý f52b1dd55d Fix config.h include before gd.h to get the HAVE_VISILIBITY symbol available 2013-04-12 15:01:43 +02:00
pierrejoye e20413bf6b - apply same CS everywhere 2013-04-03 14:23:11 +02:00
tabe 53d6320309 fixed possible segfaults when gdNewDynamicCtx() returns null 2009-06-25 19:05:45 +00:00
tabe e27c3c7f2c fix for FS#204
* gdImageCreateFrom*() returns null if null pointer given
* gdImage*() puts nothing if null pointer given
2009-06-18 13:35:26 +00:00
tabe 84f0bdeb96 check integer overflows. 2008-07-30 01:53:13 +00:00
pajoye 41d830e0c1 - #129:
- revert horizontal/vertical, was too confusing, it acts now like any
   application (ie. gimp/ps) instead of talking about h/v axis
 - optimize both
 - add simple example
2008-02-27 23:25:00 +00:00
pajoye f9c40d7ab2 - incorrect cast 2008-01-15 21:47:03 +00:00
pajoye f143b66f4d - drop unused variables 2008-01-05 20:43:15 +00:00
pajoye a17152c438 - #122, tga, add support for image flip (tga images can be stored
fliped)
2007-11-03 10:41:29 +00:00
mattias 6dec715653 - Overflow check 2007-10-16 22:05:55 +00:00
mattias 9bf34a0e18 - Avoid unnessessary alloc 2007-10-16 21:59:16 +00:00
mattias cc3ec6e30d - ws + comment 2007-10-16 21:51:42 +00:00
mattias 9e8f0306e8 - Performance hit 2007-10-16 21:36:49 +00:00
scottmac 663f35215b Make the spelling of color consistent with the rest of libgd, though colour is the correct way... :) 2007-10-13 18:18:27 +00:00
pajoye beb1d0c7c7 - #122:
- export new TGA functions
 - fix alpha support (32bit) in TGA
 - Add EOF macro (will ease our work while merging to php)
2007-10-08 07:21:40 +00:00
pajoye 8fe1fe254d - #122, initial TGA support (read only) 2007-10-07 19:41:52 +00:00