Skip to content

Commit d859557

Browse files
committed
#4541 Cap image upload size to prevent issues
1 parent 024da37 commit d859557

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

indra/newview/llfloaterimagepreview.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,18 @@ bool LLFloaterImagePreview::loadImage(const std::string& src_filename)
425425
return false;
426426
}
427427

428+
// raw image is limited to 256MB so need at least some upper limit that fits into that
429+
constexpr S32 MAX_IMAGE_AREA = 8096 * 8096;
430+
431+
if (image_info.getWidth() * image_info.getHeight() > MAX_IMAGE_AREA)
432+
{
433+
LLStringUtil::format_map_t args;
434+
args["PIXELS"] = llformat("%dM", (S32)(MAX_IMAGE_AREA / 1000000));
435+
436+
mImageLoadError = LLTrans::getString("texture_load_dimensions_error", args);
437+
return false;
438+
}
439+
428440
// Load the image
429441
LLPointer<LLImageFormatted> image = LLImageFormatted::createFromType(codec);
430442
if (image.isNull())

indra/newview/skins/default/xui/en/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3970,7 +3970,7 @@ Abuse Report</string>
39703970
<string name="AvatarBirthDateFormatShort">[mthnum,datetime,slt]/[day,datetime,slt]</string>
39713971

39723972
<string name="DefaultMimeType">none/none</string>
3973-
<string name="texture_load_dimensions_error">Can't load images larger than [WIDTH]*[HEIGHT]</string>
3973+
<string name="texture_load_dimensions_error">Can't load images larger than [PIXELS] pixels</string>
39743974
<string name="texture_load_format_error">Incorrect image format.</string>
39753975
<string name="texture_load_empty_file">File is empty.</string>
39763976
<string name="outfit_photo_load_dimensions_error">Max outfit photo size is [WIDTH]*[HEIGHT]. Please resize or use another image</string>

0 commit comments

Comments
 (0)