sendfile violates I/O-safety

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

阅读 src/sys/unix.rs 中链接的 Socket::sendfile 实现附近的代码,并将其文件描述符 bound 与 PR #325 中 SockRef::from 的改动进行比较。更新 sendfile,使其使用 issue 中描述的 I/O 安全描述符 trait,然后运行相关的 socket2 测试。完成标准是 API 不再通过 AsRawFd 接受原始描述符。

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

描述

Hi, I was scanning code for I/O safety violations, and found that Socket::sendfile violates I/O safety since it operates on raw fd while being declared safe:

https://github.com/rust-lang/socket2/blob/8b8b96fdaa1301698fd2b6f4de188635df4a8bd1/src/sys/unix.rs#L2481-L2491

I found that there have been an issue #218 pointing out that SockRef::from and sendfile are not I/O safe. However, that issue has been marked as fixed by pr #325, which only fixes SockRef::from, and sendfile is still not I/O safe in current latest version.

To fix it, I guess we can just do what #325 does: require F: AsFd instead of F: AsRawFd.

主要语言
Rust
星标
885
派生
328
平均合并
6 天 12 小时
30 天内合并 PR
2

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

rust-lang/socket2 的其他 Issue

查看 rust-lang/socket2 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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