Comments (10)
This error actually boils down to a problematic integer division: -2147483648 / -1
The result is bigger than INT_MAX and thus the calculation must be done on a long (not an integer that is later cast into a long). Here's my suggested patch. We don't have the same problem with URational as the unsigned nature makes it impossible to overflow the integer.
$ quilt diff
--- a/include/exiv2/value.hpp
+++ b/include/exiv2/value.hpp
@@ -1664,7 +1664,7 @@ namespace Exiv2 {
{
ok_ = (value_[n].second != 0);
if (!ok_) return 0;
- return value_[n].first / value_[n].second;
+ return (long)value_[n].first / value_[n].second;
}
// Specialization for unsigned rational
template<>
from exiv2.
from exiv2.
Raphael
You're in the right place and have the right idea. Your fix isn't correct on MacOS-X. It's been a long day. I'll get this fixed and submitted tomorrow.
I'm really delighted that you've made the effort to investigate this. Thank You very much.
Robin
from exiv2.
This matter isn't finished. Several issues:
- POC8 crashes on Linux and Visual Studio 2015 because printIFDStructure is being tricked into allocating a huge memory block. I'll add a check that he never attempts to request more memory than the size of the input file.
- INT_MIN and INT_MAX in include are -64k and 64k. I'll use LONG_MIN and LONG_MAX instead.
- ValueType::toLong(long n) should test ULONG_MAX
I'll add the code in the morning (2017-09-27)
from exiv2.
INT_MIN and INT_MAX in include are -64k and 64k. I'll use LONG_MIN and LONG_MAX instead.
What platform has such broken values? I would argue that the platform must be fixed... using
an arbitrary limit like your LARGE_INT seems rather ugly.
Also I don't understand why you make the function return 0 instead of throwing an error like in other places.
from exiv2.
How about using std::numeric_limits? It holds real limits and other stuff for each fundamental type.
from exiv2.
You are welcome to investigate this. MacOSX wouldn't compile the code using #include LONG_MIN/LONG_MAX, so I invented LARGE_INT and that seems to be good enough.
I didn't write this code, so I don't know why it returns 0. The code has been untouched for years. If we start throwing exceptions, we'll probably cause "ripple" in the test suite.
Please remember that this code is there to prevent a crash from a fuzzed file (a file with deliberately corrupted data). The code I submitted this morning is sufficient for that extreme case. Under normal conditions, the previous code has been in service for years without incident.
I sent an email to you and Luis about the priorities (from my point of view). Items 1 and 2 in that list are very important. 1 = Integrating clanmills/exiv2 into exiv2/exiv2. 2 = Teaching me to work properly with GitHub. So, while I'm happy for you to look into this matter, I'd prefer to focus on the high priority matters. If we could resolve 1 and 2 before I leave for the States on Friday afternoon, life will be good.
from exiv2.
This has been fixed on the master and backported to the 0.26 branch.
from exiv2.
from exiv2.
@carnil Again very much related to #54, so the same commits should apply.
from exiv2.
Related Issues (20)
- Lens Recognition for Sigma 24mm f/1.4 DG HSM Art HOT 2
- JXR Format support HOT 1
- Writing XMP metadata to jp2 files erases all XMP metadata in file HOT 10
- Dates are misinterpreted as XmpText HOT 2
- Lens Recognition for Yongnuo YN 35mm f/2 HOT 4
- Sony Marker Notes in converted from ARW to DNG files no longer readable by exiv2 (but still readable by exiftool) HOT 2
- Release version 0.28.2 HOT 5
- Support winget installation HOT 3
- Canon Lens incorrectly identified as Sigma Lens HOT 11
- Canon EF 100mm f/2.8L Macro IS USM not accurately detected HOT 1
- RawTherapee ART and Darktable cannot recognise correctly Tamron and Tokina lenses on Nikon camera HOT 7
- exiv2 does not register certain namespaces present in an image HOT 1
- Improve i18n test coverage
- Timeout in OSS-Fuzz
- exiv2.org website redirects to DNS page HOT 2
- Orientation: CLI tool and C++ API disagree HOT 2
- CMake build fails if samples enabled but webready disabled, due to conntest sample dependency HOT 6
- Access Violation in value.cpp HOT 3
- cmake出错了 HOT 4
- Who can make changes in Wiki?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exiv2.