🧱 Chunk is a download manager for slow and unstable servers

Unbounded response body read risks OOM; cap it to catch oversized responses #16

Open cuducos.me
Open opened by cuducos.me

Problem

downloadChunkWithContext reads the entire response body into memory with no cap (downloader.go:153-158).

Impact

  • OOM risk on servers that stream an unbounded body.
  • This is also the clean fix for the two silent-corruption bugs: capping the read with io.LimitReader(resp.Body, ChunkSize+1) and erroring on overflow catches both a Range-ignoring 200 (full body) and an oversized 206.

Suggested fix

io.LimitReader(resp.Body, d.ChunkSize+1); if more bytes arrive than requested, fail the chunk.

Sign up or Sign in to add to the discussion.