SNMP accepts malformed remote ports

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

维护者通常 1 天内回复

@somethingwithproof 已经在做这个了。

开始于 2026年11月1日。

  • #25138 来自 @somethingwithproof —— 未关闭

评估

难度
2/5
预计耗时
半天
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c
领域
networking

调研方向

该 issue 指向 SNMP 构造函数中对主机和端口的解析,报告称其使用了 atoi()。负载中没有指明文件,因此请先在 SNMP 扩展源码中定位该解析逻辑。使用报告中的两次构造函数调用进行复现,然后检查格式错误的端口是否抛出 ValueError,同时 0 和 65535 仍然可用。当两种错误情况都抛出异常,并且 SNMP 扩展 tests 目录下的 phpt 测试覆盖了这两种情况时,即为完成。

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

描述

Description

The following code:

<?php

new SNMP(SNMP::VERSION_1, '127.0.0.1:not-a-port', 'public');
new SNMP(SNMP::VERSION_1, '127.0.0.1:123junk', 'public');

does not throw an exception. The first port is interpreted as 0, and the
second is interpreted as 123.

I expected both malformed ports to result in a ValueError. The parser should
require at least one decimal digit, reject trailing characters, and enforce the
existing 0..65535 range.

PHP Version
PHP 8.4.28-dev (cli) (built: Nov  1 2026 11:27:04) (ZTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.28-dev, Copyright (c) Zend Technologies

The same permissive atoi() parsing is present on the current master branch.

Operating System

macOS 27.2 arm64

主要语言
C
星标
41.7k
派生
8.5k
平均合并
2 天 12 小时
30 天内合并 PR
144

环境准备

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

从这里开始

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

php/php-src 的其他 Issue

查看 php/php-src 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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