mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Allow values for limitInputPixels larger than 32-bit #3238
This commit is contained in:
@@ -48,6 +48,9 @@ namespace sharp {
|
||||
int32_t AttrAsInt32(Napi::Object obj, unsigned int const attr) {
|
||||
return obj.Get(attr).As<Napi::Number>().Int32Value();
|
||||
}
|
||||
int64_t AttrAsInt64(Napi::Object obj, std::string attr) {
|
||||
return obj.Get(attr).As<Napi::Number>().Int64Value();
|
||||
}
|
||||
double AttrAsDouble(Napi::Object obj, std::string attr) {
|
||||
return obj.Get(attr).As<Napi::Number>().DoubleValue();
|
||||
}
|
||||
@@ -131,7 +134,7 @@ namespace sharp {
|
||||
}
|
||||
}
|
||||
// Limit input images to a given number of pixels, where pixels = width * height
|
||||
descriptor->limitInputPixels = AttrAsUint32(input, "limitInputPixels");
|
||||
descriptor->limitInputPixels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputPixels"));
|
||||
// Allow switch from random to sequential access
|
||||
descriptor->access = AttrAsBool(input, "sequentialRead") ? VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM;
|
||||
// Remove safety features and allow unlimited SVG/PNG input
|
||||
@@ -439,7 +442,7 @@ namespace sharp {
|
||||
}
|
||||
// Limit input images to a given number of pixels, where pixels = width * height
|
||||
if (descriptor->limitInputPixels > 0 &&
|
||||
static_cast<uint64_t>(image.width() * image.height()) > static_cast<uint64_t>(descriptor->limitInputPixels)) {
|
||||
static_cast<uint64_t>(image.width() * image.height()) > descriptor->limitInputPixels) {
|
||||
throw vips::VError("Input image exceeds pixel limit");
|
||||
}
|
||||
return std::make_tuple(image, imageType);
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace sharp {
|
||||
std::string file;
|
||||
char *buffer;
|
||||
VipsFailOn failOn;
|
||||
int limitInputPixels;
|
||||
uint64_t limitInputPixels;
|
||||
bool unlimited;
|
||||
VipsAccess access;
|
||||
size_t bufferLength;
|
||||
|
||||
Reference in New Issue
Block a user