asyncbuffer: a completed JPEG read can return EOF before its first byte

未关闭 适合新手
#1,753 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go
领域
backend

调研方向

阅读 asyncbuffer/buffer.go,重点关注 AsyncBuffer.offsetAvailable 及其字节数、完成和 EOF 检查的顺序。使用 issue 生成的 JPEG 和内存读取器复现竞态,然后调整检查顺序,使已完成的缓冲区在返回 EOF 前重新检查。完成的标准是:当源在初始字节数检查与完成检查之间结束时,JPEG 检测能够成功。

由索引模型根据 Issue 内容生成。

描述

A valid JPEG can be classified as 422 Invalid source image if the background download finishes between the byte-count check and the completion check in AsyncBuffer.offsetAvailable. I reproduced it with a generated 60×1200 JPEG and an in-memory reader; no storage backend or network is needed.

Version: v4.0.24 (reproduced); v4.0.25 has the identical asyncbuffer/buffer.go. The same check order is still present on master (c8c5d1a5).

Reproduce: Block the underlying reader before its first read. Start imagetype.Detect on AsyncBuffer.Reader() with image/jpeg. At offset 0, pause immediately after the byte-count check reports no bytes. Unblock the stream, wait for the buffer to finish, and resume at the finished/EOF check.

Expected: Detect JPEG; the finished buffer contains the complete input. Actual: EOF at offset 0; format detection reports 422 Invalid source image with all 1,827 bytes buffered and no stream error. The same bytes detect directly as JPEG. Rechecking the byte count after observing finished makes the same forced ordering detect JPEG.

主要语言
Go
星标
11.1k
派生
777
平均合并
9 小时 37 分钟
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

imgproxy/imgproxy 的其他 Issue

查看 imgproxy/imgproxy 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。