[bugfix] allow store smaller PNG image than 261 bytes (#2263) (#2298)

* chore: add test of golden cases before fix of #2263

* chore: add test case to reproduce error of #2263

* [bugfix] allow store smaller PNG image than 261 bytes (#2263)
This commit is contained in:
KEINOS 2023-10-25 21:58:45 +09:00 committed by GitHub
commit 27f4659139
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 2 deletions

View file

@ -161,8 +161,8 @@ func (p *ProcessingMedia) store(ctx context.Context) error {
// and https://github.com/h2non/filetype
hdrBuf := make([]byte, 261)
// Read the first 261 header bytes into buffer.
if _, err := io.ReadFull(rc, hdrBuf); err != nil {
// Read the first 261 header bytes into buffer as much as possible.
if _, err := rc.Read(hdrBuf); err != nil {
return gtserror.Newf("error reading incoming media: %w", err)
}