diff --git a/config.go b/config.go index 315997d3..4e1bc62f 100644 --- a/config.go +++ b/config.go @@ -200,7 +200,6 @@ var conf = config{ Concurrency: runtime.NumCPU() * 2, TTL: 3600, IgnoreSslVerification: false, - MaxSrcDimension: 8192, MaxSrcResolution: 16800000, AllowInsecure: false, SignatureSize: 32, @@ -341,8 +340,10 @@ func init() { log.Fatalf("TTL should be greater than 0, now - %d\n", conf.TTL) } - if conf.MaxSrcDimension <= 0 { - log.Fatalf("Max src dimension should be greater than 0, now - %d\n", conf.MaxSrcDimension) + if conf.MaxSrcDimension < 0 { + log.Fatalf("Max src dimension should be greater than or equal to 0, now - %d\n", conf.MaxSrcDimension) + } else if conf.MaxSrcDimension > 0 { + warning("IMGPROXY_MAX_SRC_DIMENSION is deprecated and can be removed in future versions. Use IMGPROXY_MAX_SRC_RESOLUTION") } if conf.MaxSrcResolution <= 0 { diff --git a/docs/configuration.md b/docs/configuration.md index 4b9f1f85..2c4c5e18 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -38,9 +38,8 @@ $ echo $(xxd -g 2 -l 64 -p /dev/random | tr -d '\n') ### Security -imgproxy protects you from so-called image bombs. Here is how you can specify maximum image dimensions and resolution which you consider reasonable: +imgproxy protects you from so-called image bombs. Here is how you can specify maximum image resolution which you consider reasonable: -* `IMGPROXY_MAX_SRC_DIMENSION`: the maximum dimensions of the source image, in pixels, for both width and height. Images with larger actual size will be rejected. Default: `8192`; * `IMGPROXY_MAX_SRC_RESOLUTION`: the maximum resolution of the source image, in megapixels. Images with larger actual size will be rejected. Default: `16.8`; You can also specify a secret to enable authorization with the HTTP `Authorization` header for use in production environments: diff --git a/download.go b/download.go index 75b45eda..e36af142 100644 --- a/download.go +++ b/download.go @@ -64,7 +64,7 @@ func initDownloading() { } func checkDimensions(width, height int) error { - if width > conf.MaxSrcDimension || height > conf.MaxSrcDimension { + if conf.MaxSrcDimension > 0 && (width > conf.MaxSrcDimension || height > conf.MaxSrcDimension) { return errSourceDimensionsTooBig }