don't decode images that are too large

This commit is contained in:
Ted Unangst 2019-08-07 12:01:57 -04:00
parent 29334c3116
commit 1c6bb1fef4
4 changed files with 9 additions and 2 deletions

View File

@ -138,7 +138,8 @@ func savedonk(url string, name, media string, localize bool) *Donk {
data = buf.Bytes() data = buf.Bytes()
if strings.HasPrefix(media, "image") { if strings.HasPrefix(media, "image") {
img, err := image.Vacuum(&buf, image.Params{MaxWidth: 2048, MaxHeight: 2048}) img, err := image.Vacuum(&buf,
image.Params{LimitSize: 4800 * 4800, MaxWidth: 2048, MaxHeight: 2048})
if err != nil { if err != nil {
log.Printf("unable to decode image: %s", err) log.Printf("unable to decode image: %s", err)
localize = false localize = false

View File

@ -1,5 +1,9 @@
changelog changelog
-- next
+ Don't decode excessively large images and run out of memory.
-- 0.7.7 -- 0.7.7
+ Add another retry to workaround pixelfed's general unreliability. + Add another retry to workaround pixelfed's general unreliability.

2
go.mod
View File

@ -7,5 +7,5 @@ require (
golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 golang.org/x/net v0.0.0-20190620200207-3b0461eec859
humungus.tedunangst.com/r/go-sqlite3 v1.1.3 humungus.tedunangst.com/r/go-sqlite3 v1.1.3
humungus.tedunangst.com/r/webs v0.6.2 humungus.tedunangst.com/r/webs v0.6.3
) )

2
go.sum
View File

@ -23,3 +23,5 @@ humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9
humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M=
humungus.tedunangst.com/r/webs v0.6.2 h1:qnlWTYqhp4d+YKlEEX6bQyyyIf+3ZVw/7YiIAGxHupE= humungus.tedunangst.com/r/webs v0.6.2 h1:qnlWTYqhp4d+YKlEEX6bQyyyIf+3ZVw/7YiIAGxHupE=
humungus.tedunangst.com/r/webs v0.6.2/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE= humungus.tedunangst.com/r/webs v0.6.2/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE=
humungus.tedunangst.com/r/webs v0.6.3 h1:WoN32ETiAgSfOSonxj47cZmspdbmdTNbwlvVDmEDR+I=
humungus.tedunangst.com/r/webs v0.6.3/go.mod h1:Ho+nmafD/aUWF7LnH+Yl2/b0ob7f2pCkXm4onteWvLE=