2833 Commits (dba48ac3d9454096e7afaa653cb510490c4fb8d2)

Author SHA1 Message Date
Dan Čermák 1b74db8f51 [types] Add DataBuf::free()
DataBuf::release() easily cause memory leaks, when the return value is
ignored. free() provides the desired behavior, when the internal data should
just be deleted and not used further.
7 years ago
Dan Čermák 81b6d36c90 [webp] Enforce minimum read size in decodeChunks
The size parameter is only checked for upper bounds, but not for lower.
If it is too small, then created dataBuf will be too small and overflow in one
of the subsequent memcpy() calls.

This fixes #378 / CVE-2018-14046
7 years ago
Luis Díaz Más 6a203c70c0 Include missing unused.h header in convert.cpp 7 years ago
Dan Čermák b761c6d056 Remove useless casts in preview.cpp 7 years ago
Dan Čermák fe70939f54 Fix addition overflows in range checks in LoaderTiff::getData
Several checks for extracted values performed no overflow checks on the
addition. They can be tricked into passing, albeit the individual summands are
too large.
=> use Safe::add() which now aborts when an overflow occurs
This fixes #366
7 years ago
Dan Čermák f4e8ed2fd4 Catch all exceptions not caught in exiv2 cli-tool
It effectively looks the same as before, only now we don't call abort() but
instead clean up everything gracefully.
7 years ago
Dan Čermák 937a1a2bd0 Add offset_ and size_ safely in LoaderExifJpeg::LoaderExifJpeg
offset_ can become arbitrarily large and overflows once its added to size_,
this causes all kinds of problems further in the code when offset_ is used
again.
=> Use Safe::add() to catch potential overflows
This fixes #365.
7 years ago
Luis Diaz Mas abf6e8ec27 Remove code related with autotools 7 years ago
tbeu 6b1615840f Remove redundant check
V547 Expression 'bPrint' is always true. rafimage.cpp 112
V547 Expression 'bPrint' is always true. rafimage.cpp 125
V547 Expression 'bPrint' is always true. rafimage.cpp 136
V547 Expression 'bPrint' is always true. rafimage.cpp 147
V547 Expression 'bPrint' is always true. rafimage.cpp 158
V547 Expression 'bPrint' is always true. rafimage.cpp 169
V547 Expression 'bPrint' is always true. rafimage.cpp 190
V547 Expression 'bPrint' is always true. rafimage.cpp 213
V547 Expression 'bPrint' is always true. rafimage.cpp 236
V547 Expression 'bPrint' is always true. rafimage.cpp 252
V547 Expression 'bPrint' is always true. rafimage.cpp 262
V547 Expression 'bPrint' is always true. rafimage.cpp 272
7 years ago
tbeu eca251865f Fix check (on comparing unsigned minus signed greater zero)
V555 The expression 'object->sizeDataArea_ - buf.size_ > 0' will work as 'object->sizeDataArea_ != buf.size_'. tiffvisitor.cpp 911
7 years ago
tbeu bb9034e029 Do not implicitly cast enum to Boolean
V768 The expression 'fileProtocol(path)' is of enum type. It is odd that it is used as an expression of a Boolean-type. futils.cpp 288
7 years ago
tbeu 12d0da619b Use clear to reset string
V815 Decreased performance. Consider replacing the expression 'token = ""' with 'token.clear()'. http.cpp 193
7 years ago
tbeu 9569ef2fda Use auxiliary variable
V807 Decreased performance. Consider creating a reference to avoid using the 'image_.exifData()' expression repeatedly. preview.cpp 530
7 years ago
tbeu 75cdbc8b91 Use pre-increment on iterators
V803 Decreased performance. In case 'userEnd' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. futils.cpp 405
V803 Decreased performance. In case 'authEnd' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. futils.cpp 410
V803 Decreased performance. In case 'hostEnd' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. futils.cpp 428
V803 Decreased performance. In case 'e' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. epsimage.cpp 711
V803 Decreased performance. In case 'e' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. epsimage.cpp 841
V803 Decreased performance. In case 'e' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. epsimage.cpp 958
V803 Decreased performance. In case 'i' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. epsimage.cpp 855
V803 Decreased performance. In case 'it' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. jpgimage.cpp 817
V803 Decreased performance. In case 'lib' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. version.cpp 508
V803 Decreased performance. In case 'it' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. version.cpp 563
V803 Decreased performance. In case 'it' is iterator it's more effective to use prefix form of increment. Replace iterator++ with ++iterator. xmpsidecar.cpp 138
7 years ago
tbeu e5a4f1cf35 Use auxiliary variable
V807 Decreased performance. Consider creating a reference to avoid using the 'image.exifData()' expression repeatedly. crwimage.cpp 1320
7 years ago
tbeu 3674ce2c1d Remove superfluous assignment
V519 The 'md_st' variable is assigned values twice successively. Perhaps this is a mistake. Check lines: 155, 156. easyaccess.cpp 156
7 years ago
tbeu 9c507b9d20 Fix function declaration
V762 It is possible a virtual function was overridden incorrectly. See third argument of function 'printStructure' in derived class 'TiffImage' and base class 'Image'. tiffimage.hpp 93
7 years ago
Luis Díaz Más 9f67edd9bd Conan: bring libiconv dependency for Windows 7 years ago
Luis Díaz Más e82cd1734c Fix warnings reported by -Wmisleading-indentation 7 years ago
Luis Díaz Más 88ba920962 Extract out common code for two switch-cases into a function to fix warning
The warning was caused by -Wimplicit-fallthrough:
https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/

I also realized that the method printStructure was duplicated in the
classes Print and Erase. By moving the implementation to a free function
into the cpp file, I could remove the duplication in the code.
7 years ago
Luis Díaz Más 335607054c Use enforce instead of std::assert to fix warning about unused variable in realease mode 7 years ago
Luis Diaz Mas 773bdfd14e Create a header where to keep an unique definition of UNUSED 7 years ago
Luis Diaz Mas 9586928d29 Add CMake code to handle external XMP
Experiment: Try with testing package
7 years ago
Dan Čermák a1a9c3d79a Use reinterpret_cast instead of C style cast 7 years ago
Dan Čermák b51b6fc52d Prevent an out of bounds read in strstr in JpegBase::printStructure
The xmp byte array is not necessarily null terminated => strstr can read beyond
the bounds of the allocated array then.
Therefore use string_from_unterminated to remedy this issue.
Also replace xmp with a std::vector, as stl functions can throw and we don't
want a memory leak.
7 years ago
Dan Čermák 510560bbd1 Prevent out of bounds read in jpgimage.cpp JpegBase::printStructure
signature is extracted from an image and can lack the terminating \0, this
causes the std::string constructor and strcmp to read beyond the bounds of the
allocated array.
=> Use string_from_unterminated to construct a std::string safely and use it
in the subsequent code & use stl functions instead of C functions
7 years ago
Dan Čermák dd52b1a832 Add helper_functions.cpp/hpp & unit tests
- add function which constructs a new std::string from a potentially not null
  terminated char *
- add unit tests
7 years ago
Luis Diaz Mas 59493d1edc Fix bug in Cr2Header::read 7 years ago
Luis Diaz Mas 1d27c21639 Rename files from cr2image_int to cr2header_int 7 years ago
Luis Diaz Mas 67a5a74115 Throw when trying to write out of the buffer 7 years ago
Luis Diaz Mas 863aaebc92 Use index to access buf.pData_ 7 years ago
Luis Diaz Mas ed874703ad Prevent call to memcpy with size==0 7 years ago
Luis Diaz Mas f17636460f Remove tags_int.cpp that was not used in the project
I introduced that file accidentally in the project while trying to move
the implementation details to xxx_int.cpp files. In this case, I found
out some issues and I just decided to leave the implementation in the
file tags.cpp.
7 years ago
Luis Diaz Mas 1371d677f9 Remove custom messages from enforce(xxx, Exiv2::kerCorruptedMetadata) 7 years ago
Luis Diaz Mas c0a879aea4 Fix call to std::count, so that we count until the end of the array 7 years ago
Luis Diaz Mas 3ad0050469 Check validity of compressionFlag & compressionMethod 7 years ago
Luis Diaz Mas 2fb00c8a16 Analyze minimum needed number of null separators in PngChunk::parseTXTChunk
This commit fixes the heap-buffer-overflow in PngChunk::parseTXTChunk.

According to the specification:
http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html

There must be 2 null separators when we start to analyze the language tag.
7 years ago
Luis Diaz Mas a227fcda39 debug: Add new debug message to print the PNG chunk being processed 7 years ago
Luis Diaz Mas b0696d4da6 style: Apply formatting guidelines to one-line ifs 7 years ago
Luis Diaz Mas 4922df6018 Replace '\n' by endl that flush content. Useful for debugging 7 years ago
Luis Díaz Más c3629117d8 conan: Upgrade libcurl version
Thanks to this upgrade the cmake code that handles the CURL dependency
can be simplified. Now we can use the shared version of CURL in all the
platforms. However we will use for the moment the static version on Mac,
since we are having some issues with 'make tests'. Once those tests are
migrated to python we can also use the shared version there.
7 years ago
Daniel Zucchetto 4e55af8691
Support Canon M100 7 years ago
Dan Čermák 4b24e011dc Free potentially allocated regexes from Params::evalGrep
In Params::evalGrep regcomp allocates some internal space for the regex objects,
which must be freed manually via regfree(). This was however only done when the
call to regcomp() failed and not on success. As the regexes are needed later,
they have to be deallocated by the destructor.
7 years ago
Dan Čermák bf51a76e4e [safe_op] Fix ODR violation in compiler builtin specializations
The compiler instrinsics are exposed via fully specialized template functions
which must not be defined twice (which they accidentally were). Declaring them
as inline fixes this issue.
7 years ago
Dan Čermák 1d7dd0892c Fix errors not being passed by reference to error() function
- error was passed by value, but a new error message should be appended to it
  => error must be called by reference
- use default parameters of error() in http()
- rename variables to fix shadowing
7 years ago
Dan Čermák 571f97e277 Use __attribute__((format)) in clang too 7 years ago
Dan Čermák 222c65be63 Refactor Nikon case in bigtiffimage
- remove name shadowing
- user std::vector<> instead of raw array
7 years ago
Dan Čermák 4c4d568036 Enforce a valid Value (instead of assert) 7 years ago
Dan Čermák e2b06856d8 Change type of size to uint64_t to avoid a useless cast
The variable size is only populated via getUint64_t => uint64_t is better suited
then unsigned long
7 years ago
Dan Čermák 316548d2de Fix shadowing issues
- renamed variables that were shadowing a previously defined variables
7 years ago
Dan Čermák 5e36363138 Fix double promotion issues 7 years ago
Dan Čermák bc58752d18 Remove useless casts
This commit removes only casts where type A is cast to the exactly same
type (and not to a platform dependent typedefs)
7 years ago
Dan Čermák bb2019149a [safe_op] Don't use overflow intrinsics in MSVC 2005 7 years ago
Luis Díaz Más e32323d7c7 Simplify usage of strerror_r.
- Define STRERROR_R_CHAR_P properly on CMake and use it on futils.cpp
- We use now _GNU_SOURCE to determine which version of strerror_r to use
- strError only throws if ret==ERANGE
- Remove STRERROR_R_CHAR_P. It has been never used
- sort defines in config.h.cmake
- Remove EXV_HAVE_DECL_STRERROR_R that is not used anymore
- Remove EXV_HAVE_STRERROR. C++98 always will have it
7 years ago
Robin Mills d22fff4834 Lens Recognition for Tamron SP AF 150-600mm F/5-6.3 VC USD G2 (A022) for Nikon
http://dev.exiv2.org/issues/1348
7 years ago
Luis Díaz Más f86542e5f6 Remove EXV_HAVE_STRTOL 7 years ago
Luis Díaz Más d55b2b1b65 Remove HAVE_STDLIB_H check and replace stdlib.h by cstdlib 7 years ago
Luis Díaz Más aded1965c5 Remove EXV_HAVE_MEMSET 7 years ago
Luis Díaz Más abd28a6a9e Remove EXV_HAVE_STRCHR 7 years ago
Dan Čermák fc60d97a29 Prevent passing of null-pointers to libc functions 7 years ago
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.
7 years ago
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.
7 years ago
Luis Díaz Más fbd8e2669e sort alphabetically the sources in src/CMakelists.txt 7 years ago
Luis Díaz Más de5b9ebf89 Remove duplication of sources in src/CMakeLists.txt 7 years ago
Luis Díaz Más ffbcaa2e6d Fix MSVC warning C4267: conversion from 'size_t' to 'long' 7 years ago
Luis Díaz Más bd40c18f1c Use variable in TimeValue::copy to remove -Wunused-variable warning 7 years ago
Luis Diaz Mas a246c73d6f Use unused variable instead of hard-coded values in DateValue::copy 7 years ago
Luis Díaz Más bf7047a71b clang-format XmpKey code 7 years ago
Luis Diaz Mas 07d75cd0e8 Check if ExifData::findKey return valid iterators 7 years ago
Luis Díaz Más 858c99b4df Add enforce before calling REPORT_MARKER with invalid marker 7 years ago
Luis Díaz Más 5e5d76ad0a clang format function 7 years ago
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.
7 years ago
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
7 years ago
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()
7 years ago
HumanDynamo 22a0b32c01 Fix typo of Xmp.video.AspectRatio's value type 7 years ago
Luis Díaz Más 01a5d863ad Apply clang-format to Print::printMetadatum 7 years ago
Luis Díaz Más 45fe44aa2f Move condition in if statement to discard work earlier 7 years ago
Luis Díaz Más d82b9434e1 Only print items (Params::prValue) when size > 0 7 years ago
Robin Mills 185d0e9482 #199 Fix for getopt(). Use src/getopt_win32 code instead of libc/getopt() 7 years ago
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
7 years ago
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.
7 years ago
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.
7 years ago
Dan Čermák 029b997ca0 [safe_op] fixed typo in doc-comment 7 years ago
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
7 years ago
Fredrik lingvall fc8b45dd12 Added the Sigma 120-300mm F2.8 DG OS HSM | S for Nikon mount. 7 years ago
Fredrik lingvall 34a3be025e Added Sigma 50mm F1.4 DG HSM | A mount/UPC code (for Nikon mount). 7 years ago
Fredrik Lingvall 215227024d Added Sigma 20mm F1.4 DG HSM | A mount/UPC code (for Nikon mount). 7 years ago
Dan Čermák efe2ccdcb6 Replaced all hardcoded error codes with ker... constants 7 years ago
Dan Čermák d3c3c036b8 Incorporated error codes into errList 7 years ago
Robin Mills 55001c8ddf
Merge pull request #222 from Exiv2/fix-220
Fix 220
7 years ago
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
7 years ago
Robin Mills a1f1989cb5
Merge branch 'master' into master 7 years ago
clanmills c082537967 Fix #220 https://github.com/Exiv2/exiv2/issues/220 8 years ago
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)
8 years ago
Robin Mills df4113b765 changes to MemIo::reserve() for #200 (#213)
* changes to MemIo::reserve() for #200

* Changes following review by Dan (thanks, Dan).
8 years ago
Michał Walenciak d219e61586 be more error prone 8 years ago
Michał Walenciak 24348e85ca checks for valid reads 8 years ago
Michał Walenciak 421c6d6723 improvements for issue #208 8 years ago
Michał Walenciak 1647908e00 fix for crash in bigtiff (issue #208) 8 years ago
Robin Mills 7d42da94d0 Removed wrong ExifData::const_iterator that shadowed the correct one 8 years ago