Commit Graph

2724 Commits

Author SHA1 Message Date
Dan Čermák
fc60d97a29 Prevent passing of null-pointers to libc functions 2018-04-25 00:13:41 +02:00
Dan Čermák
2bf89f4854 Store pointers to Impl classes in auto_ptr
Pimpl class Impl is stored in raw pointers which are allocated on the heap in
the constructor. However, the constructor can throw an exception resulting in a
memory leak as the destructor is **not** invoked.
=> A smart pointer is however properly deallocated.
2018-04-25 00:13:26 +02:00
Luis Díaz Más
02aa13abf3 Install conan-dependencies DLLs into install/bin.
We also changed the way in which we copy the DLLs to the bin folder inside the build directory.
Before we were directly placing the conan-deps DLLs into the bin folder directly. Now we place
them into a directory called conanDlls, and from there we copy them to bin or install/bin
at build and install steps respectively.
2018-04-19 17:19:47 +02:00
Luis Díaz Más
fbd8e2669e sort alphabetically the sources in src/CMakelists.txt 2018-04-09 23:04:35 +02:00
Luis Díaz Más
de5b9ebf89 Remove duplication of sources in src/CMakeLists.txt 2018-04-09 23:04:35 +02:00
Luis Díaz Más
ffbcaa2e6d Fix MSVC warning C4267: conversion from 'size_t' to 'long' 2018-04-09 15:54:27 +02:00
Luis Díaz Más
bd40c18f1c Use variable in TimeValue::copy to remove -Wunused-variable warning 2018-04-08 10:10:12 +02:00
Luis Diaz Mas
a246c73d6f Use unused variable instead of hard-coded values in DateValue::copy 2018-04-08 10:10:12 +02:00
Luis Díaz Más
bf7047a71b clang-format XmpKey code 2018-04-07 20:04:22 +02:00
Luis Diaz Mas
07d75cd0e8 Check if ExifData::findKey return valid iterators 2018-04-02 17:46:29 +02:00
Luis Díaz Más
858c99b4df Add enforce before calling REPORT_MARKER with invalid marker 2018-04-01 08:20:22 +02:00
Luis Díaz Más
5e5d76ad0a clang format function 2018-03-30 08:10:58 +02:00
Dan Čermák
3c20cc06a9 Fix CVE-2017-1000126
CVE-2017-1000126 is a Stack out of bounds read in the WebP parser caused by the
parameter size & filesize being too large, causing the parser to land in an
infinite loop and eventually crash. Enforcing that the size over which the
parser iterates is smaller than the file fixes this issue.

This fixes #175.
2018-03-27 23:46:13 +02:00
Dan Čermák
49db96cd58 [webp] Fix wrong filesize parameter being extracted from the header
The webp header contains the filesize of the image starting at the 8th byte in
bytes 4 to 8 encoded as a little endian 32 bit unsigned integer. The code was
erroneously assuming that the extracted filesize is starting at the 12th byte,
i.e. at the end of the WebP file header.

Source: https://developers.google.com/speed/webp/docs/riff_container
2018-03-27 23:46:13 +02:00
Dan Čermák
5de9a7b562 Add a port of enforce() from D
enforce is a function comparable to assert(), it ensures that a condition is
true. However, while assert() should be used for conditions where we can be
certain that they are true, enforce is intended to be used for conditions that
can fail (like on invalid input). Therefore enforce() throws an exception when
the condition is false and does not abort the program's execution. Also, it is
not turned off by defining NDEBUG.

- add a new file enforce.hpp
- implement enforce()
2018-03-25 23:25:11 +02:00
HumanDynamo
22a0b32c01 Fix typo of Xmp.video.AspectRatio's value type 2018-03-24 09:11:32 +01:00
Luis Díaz Más
01a5d863ad Apply clang-format to Print::printMetadatum 2018-03-20 21:30:06 +01:00
Luis Díaz Más
45fe44aa2f Move condition in if statement to discard work earlier 2018-03-20 21:30:06 +01:00
Luis Díaz Más
d82b9434e1 Only print items (Params::prValue) when size > 0 2018-03-20 21:30:06 +01:00
Robin Mills
185d0e9482 #199 Fix for getopt(). Use src/getopt_win32 code instead of libc/getopt() 2018-03-20 18:49:16 +01:00
Dan Čermák
06ec1e6984 [safe_op] Refactored addition overflow checks using functions only
- templated structs were not required, SFINAE works for functions too
  => use instead, removes some unneeded code
- fix non-usage of builtins with clang
- adjust unit tests
2018-03-09 00:14:24 +01:00
Dan Čermák
684c8c89de [safe_op] Simplified unsigned int overflow check
Simply check for overflows after the addition, as no undefined behavior can
occur here.
2018-03-08 00:34:14 +01:00
Dan Čermák
31b96b58e7 [safe_op] improved signed int overflow checks via integer promotion
The fallback signed integer overflow check is quite expensive, but the addition
can be safely performed when saved in an int due to integer promotion
rules. This makes the check a little less expensive.
2018-03-08 00:32:14 +01:00
Dan Čermák
029b997ca0 [safe_op] fixed typo in doc-comment 2018-03-08 00:31:02 +01:00
Dan Čermák
751fba8b54 Added dataBuf size check before calling PngChunk::decodeIHDRChunk
- cdataBuf must be at least 8 bytes long otherwise decodeIHDRChunk
  reads out of bounds
- pngImage::readMetadata now skips png chunks where the offset for
  IHDR chunks is invalid
- added assertion into PngChunk::decodeIHDRChunk() to ensure dataBuf
  size
2018-02-22 14:55:12 +01:00
Fredrik lingvall
fc8b45dd12 Added the Sigma 120-300mm F2.8 DG OS HSM | S for Nikon mount. 2018-02-21 12:56:42 +01:00
Fredrik lingvall
34a3be025e Added Sigma 50mm F1.4 DG HSM | A mount/UPC code (for Nikon mount). 2018-02-21 12:56:42 +01:00
Fredrik Lingvall
215227024d Added Sigma 20mm F1.4 DG HSM | A mount/UPC code (for Nikon mount). 2018-02-21 12:56:42 +01:00
Dan Čermák
efe2ccdcb6 Replaced all hardcoded error codes with ker... constants 2018-02-18 09:28:57 +01:00
Dan Čermák
d3c3c036b8 Incorporated error codes into errList 2018-02-18 09:26:47 +01:00
Robin Mills
55001c8ddf
Merge pull request #222 from Exiv2/fix-220
Fix 220
2018-02-03 14:19:59 +00:00
Dan Čermák
fcb4257051 Add check for DataBuf.size_ in Jp2Image::readMetadata()
When parsing a subBox that is a ColorHeader, a length is extracted
from the input file and fed directly into DataBuf() (which calls
malloc). A crafted input file can provide arbitrarily (up to
max(uint32_t)-8) large values and result in excessive memory
allocation.

This commit adds a check for the new size of DataBuf so that it is not
larger than the remaining size of the file.

This fixes #202 aka CVE-2018-4868
2018-02-01 17:55:22 +01:00
Robin Mills
a1f1989cb5
Merge branch 'master' into master 2018-02-01 14:55:07 +00:00
clanmills
c082537967 Fix #220 https://github.com/Exiv2/exiv2/issues/220 2018-01-29 09:13:27 +00:00
Dan Čermák
4429b962e1 Fix out of bounds read in src/pngchunk_int.cpp by @brianmay
- consider that key is advanced by 8 bytes if stripHeader is true
  => length is reduced by same amount
  Fixed by adding offset to the check in the loop
- Rewrote loop so that keysize is checked before the next
  iteration (preventing an out of bounds read)
2018-01-27 14:51:40 +01:00
Robin Mills
df4113b765 changes to MemIo::reserve() for #200 (#213)
* changes to MemIo::reserve() for #200

* Changes following review by Dan (thanks, Dan).
2018-01-26 09:19:03 +01:00
Michał Walenciak
d219e61586 be more error prone 2018-01-17 19:07:41 +01:00
Michał Walenciak
24348e85ca checks for valid reads 2018-01-15 21:44:41 +01:00
Michał Walenciak
421c6d6723 improvements for issue #208 2018-01-14 08:24:26 +01:00
Michał Walenciak
1647908e00 fix for crash in bigtiff (issue #208) 2018-01-13 11:44:31 +01:00
Robin Mills
7d42da94d0 Removed wrong ExifData::const_iterator that shadowed the correct one 2018-01-06 00:07:36 +01:00
Luis Díaz Más
00f32316b2 Add missing header 2017-12-21 16:33:14 +01:00
Luis Díaz Más
14ff034fb4 Catch std::overflow_error exception in Print::run 2017-12-21 16:33:14 +01:00
Luis Diaz Mas
d09c4bb7cd Fix arithmetic operation overflow 2017-12-21 16:33:14 +01:00
Luis Díaz Más
a1023c39ab Add safe_op.hpp to LIBEXIV2_PRIVATE_HDR (to be shown in IDEs) 2017-12-17 20:35:07 +01:00
Dan Čermák
7c00e9128d Fix compilation error with gcc < 5
- overflow builtins were added with gcc 5.0
2017-12-17 20:35:07 +01:00
Dan Čermák
ca7c699aa1 Added overflow safe addition function 2017-12-17 20:35:07 +01:00
Robin Mills
8f5b795eaa Fixes to autotools build to respect mn_int.cpp files (#186)
* Fixes to autotools build to respect mn_int.cpp files

* Changes following Luis' code review.
2017-12-11 16:48:07 +01:00
Luis Díaz Más
f36bea3801 exiv2::getEnv throws std::out_of_range on unexpected EnVar
This change define explicitly the behavior that exiv2::getEnv should have
on response to unexpected inputs.

There are some other minor changes:

- Use _putenv_s for the unit tests on Windows
- Add todo comment
- Remove deprecated note about freeing memory
2017-12-06 17:29:05 +01:00
Luis Díaz Más
8dc3c1f0a0 Replace malloc/free by new/delete. Use const char* for input arg 2017-12-06 17:29:05 +01:00