24.03.2015 Views

开放源代码软件JQuery 成熟度评估报告 - 开源中国社区- 软件镜像下载

开放源代码软件JQuery 成熟度评估报告 - 开源中国社区- 软件镜像下载

开放源代码软件JQuery 成熟度评估报告 - 开源中国社区- 软件镜像下载

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

开 放 源 代 码 软 件 JQuery 成 熟 度 评 估 报 告<br />

编 制 : 贾 训 凯 杨 勇<br />

时 间 :2011 年 03 月 5 日<br />

工 业 和 信 息 化 部 软 件 与 集 成 电 路 促 进 中 心


目 录<br />

Lighttpd 软 件 介 绍 ..................................................................................................................... 3<br />

体 系 架 构 ............................................................................................................................ 9<br />

分 析 结 论 .......................................................................................................................... 10<br />

Lighttpd 软 件 代 码 质 量 评 测 报 告 ................................................................................. 11<br />

评 测 工 具 介 绍 .......................................................................................................... 11<br />

评 测 分 析 .................................................................................................................. 11<br />

Lighttpd 易 用 性 研 究 ............................................................................................... 12<br />

Lighttpd 可 用 性 性 研 究 ........................................................................................... 12<br />

License 问 题 ............................................................................................................ 13<br />

软 件 成 熟 度 评 估 ...................................................................................................... 13<br />

Lighttpd 软 件 成 熟 度 评 估 结 论 ....................................................................................... 17<br />

总 结 .................................................................................................................................. 18<br />

参 考 .................................................................................................................................. 18<br />

附 录 .................................................................................................................................. 18


Lighttpd 软 件 介 绍<br />

Lighttpd 是 一 个 德 国 人 领 导 的 开 源 软 件 , 其 根 本 的 目 的 是 提 供 一 个 专 门 针<br />

对 高 性 能 网 站 的 安 全 、 快 速 、 兼 容 性 好 并 且 灵 活 的 Web 服 务 器 环 境 。 具 有 非 常<br />

低 的 内 存 开 销 ,CPU 占 用 率 低 , 效 能 好 , 以 及 丰 富 的 模 块 等 特 点 。Lighttpd 是<br />

众 多 开 源 轻 量 级 的 Web 服 务 器 中 较 为 优 秀 的 一 个 。 支 持 FastCGI, CGI, Auth, 输<br />

出 压 缩 (output compress), URL 重 写 , Alias 等 重 要 功 能 , 而 Apache 之 所 以 流 行 ,<br />

很 大 程 度 也 是 因 为 功 能 丰 富 , 在 Lighttpd 上 很 多 功 能 都 有 相 应 的 实 现 了 , 这 点 对<br />

于 Apache 的 用 户 是 非 常 重 要 的 , 因 为 迁 移 到 Lighttpd 就 必 须 面 对 这 些 问 题 。<br />

Lighttpd 是 一 个 性 能 非 常 优 异 的 轻 量 级 开 源 Web 服 务 器 。Lighttpd 可 以 轻<br />

松 支 撑 上 万 的 并 发 , 在 单 台 服 务 器 上 支 撑 到 3 万 并 发 也 不 是 问 题 , 并 且 请 求 的<br />

处 理 速 度 也 非 常 快 , 比 Apache 要 快 3~5 倍 。Lighttpd 支 持 Web2.0, 支 持<br />

PHP、Python 和 Ruby 等 脚 本 语 言 。<br />

Lighttpd 主 要 特 性 如 下 :<br />

• 提 供 FastCGI 及 SCGI 的 负 载 平 衡 ;<br />

• 支 持 chroot;<br />

• 支 持 select()/poll() 及 更 有 效 率 的 kqueue/epoll 连 接 状 态 判 断 ;<br />

• 支 持 条 件 重 写 (Conditional rewrites);


• 支 持 SSL 连 接 ;<br />

• 通 过 LDAP server 认 证 ;<br />

• rrdtool 状 态 输 出 ;<br />

• 基 于 规 则 (Rule-based) 的 下 载 ;<br />

• 服 务 器 端 包 含 支 持 ;<br />

• 虚 拟 主 机 ;<br />

• 模 块 化 支 持 ;<br />

• 元 数 据 缓 存 语 言 ;<br />

• 最 小 WebDAV 支 持 ;<br />

• Servlet (AJP) 支 持 (1.5.x 版 后 )。<br />

Lighttpd 软 件 的 主 要 组 件 模 块 :<br />

mod_accesslog – 缺 省 为 通 用 日 志 格 式 , 像 Apache 一 样 灵 活 。<br />

mod_access – 访 问 模 块 用 来 对 部 分 文 件 的 访 问 控 制 。<br />

mod_alias – alias 模 块 是 用 来 对 给 定 的 一 个 url-subset 指 定 一 个 专 门 的 document-


oot。<br />

mod_auth – Lighttpd 支 持 RFC 2617 描 述 的 两 种 身 份 验 证 方 法 。<br />

mod_cgi – cgi 程 序 提 供 了 非 常 直 接 和 简 单 的 方 法 用 来 增 强 服 务 器 的 功 能 。<br />

mod_cml – CML( 缓 存 元 语 言 ) 要 解 决 一 下 几 个 问 题 :<br />

• 动 态 内 容 需 要 缓 存 后 执 行<br />

• 检 查 应 用 的 内 容 是 否 为 脏 通 常 比 把 缓 存 数 据 发 送 出 去 要 费 时<br />

• 动 态 页 面 通 常 是 被 分 割 成 片 段 的 , 并 且 不 同 片 段 有 不 同 的 生 命 周 期<br />

• 不 同 的 片 段 能 被 独 立 的 缓 存<br />

mod_compress – 压 缩 输 出 能 降 低 网 络 负 载 , 并 且 能 改 善 web 服 务 器 的 整 体 吞 吐<br />

量 。 所 有 主 流 的 http 客 户 端 都 支 持 在 Accept-Encoding 头 中 声 明 过 的 压 缩 , 这<br />

是 最 合 适 的 压 缩 方 法 , 此 模 块 可 以 支 持 deflate、gzip 和 bzip2 压 缩 。deflate<br />

(RFC1950, RFC1951) 和 gzip (RFC1952) 依 赖 zlib 而 bzip2 依 赖 libbzip2, 只 有<br />

lynx 和 一 些 其 它 的 文 本 浏 览 器 才 支 持 bzip2。 当 前 只 支 持 静 态 页 面 的 压 缩 。<br />

mod_dirlisting – 列 出 目 录 模 块 , 是 默 认 加 载 模 块 之 一 , 不 需 要 在 server.modules<br />

中 指 定 就 可 以 工 作 。 如 果 请 求 一 个 目 录 并 且 此 目 中 又 没 有 索 引 文 件 , 那 么 会 生 成 一<br />

个 列 表 。<br />

mod_evasive – 是 一 个 非 常 简 单 的 模 块 , 用 来 限 制 每 一 个 IP 的 链 接 。<br />

mod_evhost – 增 强 型 主 机 ,mod_evhost 基 于 一 种 包 含 通 配 符 的 模 式 构 建 文 件 主<br />

机 , 这 些 通 配 符 可 以 代 表 提 交 的 部 分 主 机 名 。<br />

%% => % sign<br />

%0 => domain name + tld<br />

%1 => tld


%2 => domain name without tld<br />

%3 => subdomain 1 name<br />

%4 => subdomain 2 name<br />

%_ => full domain name<br />

evhost.path-pattern = "/home/www/servers/%3/pages/"<br />

mod_expire – 控 制 缓 存 中 内 容 的 过 期 时 间 , 控 制 过 期 时 间 和 缓 存 控 制 :<br />

HTTP/1.0 和 HTTP/1.1 响 应 头 中 的 max-age 字 段 。 用 它 来 设 置 一 些 需 要 缓 存 的 静<br />

态 文 件 , 像 图 像 和 样 式 表 等 是 很 有 用 的 。<br />

mod_extforward – 这 个 模 块 用 来 从 X-Forwarded-For 报 头 中 提 取 出 客 户 端 的 真 实<br />

IP,X-Forwarded-For 报 头 是 Squid 或 者 其 他 代 理 添 加 的 。 这 也 许 对 反 向 代 理 服 务<br />

器 后 面 的 服 务 器 是 有 用 的 。<br />

mod_fastcgi – FastCGI 接 口 。Lighttpd 为 支 持 FastCGI 接 口 的 外 部 程 序 提 供 接 口 。<br />

FastCGI 接 口 是 在 http://www.fastcgi.com/ 中 定 义 的 , 并 且 是 web 程 序 和 web 服 务<br />

器 之 间 平 台 独 立 、 服 务 器 独 立 的 接 口 。<br />

mod_magnet - mod_magnet 是 lighty 中 用 来 控 制 请 求 处 理 的 模 块 , 它 可 以 让 你 做<br />

更 复 杂 的 URL 重 写 和 缓 存 。<br />

mod_mysql_vhost- 基 于 MySQL 的 虚 拟 主 机 。 使 用 基 于 MySQL 的 虚 拟 主 机 , 可<br />

以 存 储 数 据 到 MySQL 数 据 库 中 给 定 的 主 机 目 录 。<br />

mod_proxy – 支 持 代 理 服 务 。<br />

mod_redirect – URL 重 定 向 , 用 来 指 定 一 组 URL 的 重 定 向 。


mod_rewrite – URL 重 写 , 内 部 重 定 向 ,URL 重 写 。<br />

mod_rrdtool – RRD 是 用 来 存 储 和 显 示 基 于 时 间 轴 的 数 据 ( 例 如 网 络 带 宽 、 机 房 温<br />

度 和 服 务 器 平 均 负 载 等 )<br />

mod_scgi – SCGI 接 口 。 当 涉 及 到 配 置 的 时 候 ,SCGI 主 要 基 于 FastCGI。 只 有 服 务<br />

器 和 客 户 端 之 间 的 内 部 协 议 替 换 了 。 请 参 考 FastCGI 模 块 的 文 档 了 解 更 多 信 息 。<br />

mod_secdownload – 安 全 和 快 速 下 载 模 块 。 有 多 种 方 法 可 以 实 现 安 全 下 载 机 制 :<br />

1) 使 用 网 络 服 务 器 和 内 部 HTTP 认 证<br />

2) 使 用 应 用 程 序 认 证 并 且 通 过 应 用 程 序 发 送 文 件<br />

这 两 种 方 式 都 有 局 限 性 服 务 器 方 式 :<br />

• 快 速 下 载<br />

• 没 有 额 外 的 系 统 负 担<br />

• 僵 化 的 认 证 处 理 应 用 程 序 方 式 :<br />

• 集 成 到 整 个 系 统 中<br />

• 非 常 灵 活 的 权 限 管 理<br />

• 下 载 要 占 用 一 个 进 程 或 线 程 把 这 两 种 方 式 结 合 起 来 的<br />

简 单 方 法 是 :<br />

1) 由 应 用 程 序 验 证 用 户 并 检 查 下 载 文 件 的 权 限<br />

2) 由 应 用 程 序 重 定 向 用 户 到 文 件 , 此 文 件 可 以 被 服 务 器 所 访 问 以 便<br />

提 供 进 一 步 的 下 载<br />

3) Web 服 务 器 的 文 件 传 输 给 用 户<br />

mod_simple_vhost – 简 单 虚 拟 主 机 模 块 。<br />

mod_ssi – SSI 是 一 种 比 较 老 的 在 服 务 器 端 产 生 动 态 网 页 的 方 式 。


不 建 议 使 用 这 个 模 块 , 因 为 :<br />

• 在 服 务 器 核 心 执 行 SSI 脚 本<br />

• 一 个 长 时 间 运 行 的 SSI 脚 本 会 阻 止 处 理 所 有 其 它 连 接<br />

• 只 要 你 使 用 #EXEC 性 能 会 不 如 直 接 使 用 CGI 脚 本 好<br />

有 两 个 原 因 你 只 能 使 用 SSI:<br />

• 包 含 #include 的 内 容<br />

• 旧 的 应 用 程 序<br />

mod_status – 服 务 器 状 态 模 块 生 成 Web 服 务 器 的 状 态 概 述 , 包 括 的 信 息 如 下 :<br />

• 正 常 运 行 时 间<br />

• 平 均 吞 吐 量<br />

• 当 前 吞 吐 量<br />

• 当 前 活 动 的 连 接 和 它 们 的 状 态<br />

mod_userdir – userdir 模 块 可 以 简 单 的 把 用 户 目 录 和 web 服 务 器 全 局 命 名 空 间 连 接<br />

起 来 。<br />

mod_usertrack - 点 击 流 是 由 网 站 的 访 问 者 浏 览 网 站 时 执 行 的 页 面 访 问 和 相 关 的<br />

点 击 。 Usertrack 模 块 设 置 一 个 用 户 端 的 cookie, 以 便 点 击 流 日 志 来 跟 踪 用 户 的 活<br />

动 。<br />

mod_webdav - WebDAV 模 块 是 RFC 2518 的 简 单 实 现 , 所 谓 简 单 实 现 就 是 只 实 现<br />

了 部 分 操 作 , 目 前 只 有 :<br />

• PROPFIND<br />

• OPTIONS<br />

• MKCOL<br />

• DELETE


• PUT<br />

• LOCK (experimental)<br />

和 常 用 的 GET, POST, HEAD 操 作 。<br />

体 系 架 构<br />

在 Lighttpd 中 , 使 用 插 件 的 形 式 来 增 加 服 务 的 功 能 。 同 时 ,Lighttpd 提 供 了<br />

一 个 插 件 的 公 共 接 口 给 开 发 者 , 方 便 第 三 方 提 供 额 外 的 插 件 。Lighttpd 的 插 件 接 口<br />

主 要 提 供 在 plugin.h 文 件 中 。 其 中 ,plugin 结 构 体 是 最 核 心 的 部 分 。 在 结 构 体<br />

plugin 的 设 计 中 , 作 者 使 用 了 面 向 对 象 的 思 想 。plugin 结 构 体 就 是 一 个 虚 基 类 , 其<br />

中 的 数 据 成 员 , 如 name,version 等 都 是 子 类 公 有 的 。 而 随<br />

后 的 一 系 列 函 数 指 针 则 是 虚 函 数 , 这 些 函 数 指 针 在 plugin 结 构 体 中 并 没 有 进 行<br />

赋 值 , 要 求 所 有 的 子 类 必 须 对 其 进 行 赋 值 。 不 同 的 子 类 对 这 些 函 数 指 针 赋 不 同<br />

的 值 , 在 进 行 函 数 调 用 的 时 候 就 可 以 实 现 多 态 。<br />

另 外 ,C 语 言 毕 竟 不 支 持 面 向 对 象 , 因 此 , 在 通 过 c 实 现 面 向 对 象 的 时 候<br />

大 多 情 况 先 是 要 靠 人 的 理 解 , 而 不 是 语 言 上 的 约 束 。 如 plugin 结 构 体 是 一 个 虚<br />

基 类 , 实 际 上 所 有 的 子 类 都 是 这 个 结 构 体 的 实 例 , 而 子 类 的 实 例 只 有 一 个 , 也<br />

就 是 他 自 己 。 这 就 和 C++ 中 的 子 类 不 同 了 。<br />

在 plugin 结 构 体 中 ,version 成 员 比 较 重 要 。 很 明 显 , 这 个 成 员 标 记 这 个 插<br />

件 的 版 本 。 在 plugin 结 构 体 中 定 义 的 那 一 系 列 函 数 指 针 是 插 件 的 对 外 接 口 , 也 就<br />

是 插 件 对 Lighttpd 的 接 口 ,Lighttpd 只 知 道 这 些 接 口 , 通 过 调 用 这 些 接 口 来 完<br />

成 工 作 。 随 着 Lighttpd 的 不 断 改 进 , 这 些 接 口 可 能 满 足 不 了 服 务 器 的 要 求 , 因


此 要 对 其 进 行 改 进 , 这 样 就 有 可 能 造 成 以 前 开 发 的 插 件 无 法 使 用 。 通 过 version<br />

成 员 , 在 加 载 插 件 的 时 候 判 断 这 个 插 件 是 否 符 合 当 前 服 务 器 的 版 本 , 也 就 是 接<br />

口 是 否 相 符 。 如 果 不 相 符 , 则 不 加 载 插 件 , 这 样 就 可 以 避 免 由 于 接 口 的 不 相 符<br />

造 成 服 务 器 的 崩 溃 等 问 题 。<br />

插 件 的 加 载 和 初 始 化 的 过 程 :<br />

(1) 根 据 配 置 文 件 从 相 应 的 目 录 中 加 载 插 件 的 动 态 连 接 库 。<br />

函<br />

(2) 获 得 插 件 动 态 库 中 XXX_plugin_init 函 数 的 入 口 地 址 并 调 用 之 。 此<br />

数 对 plugin 结 构 体 进 行 赋 值 。<br />

(3) 在 server 结 构 体 中 注 册 插 件 。<br />

(4) 调 用 plugins_call_init 初 始 化 插 件 。<br />

(5) 通 过 上 面 那 个 宏 及 后 面 一 系 列 的 宏 调 用 , 将 插 件 登 记 造 册 , 记 录<br />

在 server 结 构 体 的 plugins_slots 成 员 中 。plugins_slot 是 一 个 二 维 数 组 , 数 组 成<br />

员 是 plugin 结 构 体 指 针 。<br />

(6) 最 后 调 用 插 件 的 init 函 数 初 始 化 各 自 的 plugin_data 结 构 体 。<br />

分 析 结 论<br />

本 软 件 虽 然 由 C 语 言 写 成 , 但 程 序 的 构 造 多 参 考 面 向 对 象 的 设 计 。 整 个 程 序 架<br />

构 完 整 , 结 构 灵 活 , 可 移 植 性 较 强 。 软 件 的 设 计 者 不 仅 为 用 户 停 工 了 丰 富 的 功 能 ,<br />

而 且 在 各 个 层 面 都 为 程 序 的 可 扩 展 性 和 部 署 的 灵 活 性 留 下 接 口 。 在 Lighttpd 中 ,<br />

使 用 插 件 的 形 式 来 增 加 服 务 的 功 能 。 同 时 ,Lighttpd 提 供 了 一 个 插 件 的 公 共 接 口<br />

给 开 发 者 , 方 便 第 三 方 提 供 额 外 的 插 件 。<br />

软 件 的 配 置 完 全 依 赖 于 修 改 配 置 文 件 , 没 有 配 置 工 具 。 软 件 的 设 计 中 可 能 由 于<br />

历 史 的 原 因 , 资 源 切 换 和 改 变 事 件 有 多 个 切 入 点 , 不 利 于 系 统 的 扩 展 和 灵 活 应 用<br />

( 即 一 个 单 一 的 事 件 处 理 入 口 对 软 件 是 必 要 的 )。 系 统 的 设 计 中 , 在 从 Partition<br />

故 障 中 回 复 的 动 作 设 计 的 不 够 灵 活 , 过 于 简 单 , 也 没 有 为 扩 充 留 下 相 应 的 接 口 或 介<br />

入 点 。


Lighttpd 软 件 代 码 质 量 评 测 报 告<br />

评 测 工 具 介 绍<br />

源 代 码 质 量 管 理 工 具 , 可 集 成 各 种 源 代 码 静 态 分 析 工 具 , 支 持 c/c++,java,<br />

php,pthyon 等 语 言 , 通 过 该 工 具 可 以 了 解 源 代 码 的 包 括 缺 陷 、 漏 洞 等 质 量 情 况 ,<br />

以 及 代 码 行 , 架 构 等 软 件 度 量 信 息 , 帮 助 了 解 整 体 代 码 的 成 熟 度 。 主 要 特 点 为<br />

代 码 覆 盖 : 通 过 单 元 测 试 , 将 会 显 示 哪 行 代 码 被 选 中 ; 改 善 编 码 规 则 ; 搜 寻 编<br />

码 规 则 : 按 照 名 字 , 插 件 , 激 活 级 别 和 类 别 进 行 查 询 ; 项 目 搜 寻 : 按 照 项 目 的<br />

名 字 进 行 查 询 ; 对 比 数 据 : 比 较 同 一 张 表 中 的 任 何 测 量 的 趋 势 ;<br />

RATS(Rough Auditing Tool for Security) 是 一 个 开 源 的 静 态 代 码 分 析<br />

工 具 , 它 由 Secure Software 公 司 开 发 和 维 护 ,Secure Software 公 司 已 被<br />

Fortify 软 件 公 司 收 购 (Fortify 软 件 公 司 现 已 被 HP 公 司 收 购 )。RATS 可 对 C,<br />

C++,Perl,PHP,Python 等 语 言 的 源 代 码 进 行 静 态 分 析 , 可 标 注 出 编 程 中<br />

经 常 出 现 的 安 全 性 错 误 , 例 如 : 缓 存 溢 出 , TOCTOU (Time Of Check, Time Of<br />

Use) race conditions 等 。<br />

RATS 扫 描 工 具 提 供 了 一 个 安 全 分 析 模 块 , 这 个 模 块 含 有 一 个 列 表 , 此 列 表 存<br />

储 的 是 可 能 出 现 的 安 全 问 题 以 及 处 理 建 议 。RATS 还 对 每 个 安 全 问 题 的 潜 在 危 险 程<br />

度 进 行 评 估 , 为 评 估 人 员 提 供 参 考 。RATS 还 提 供 一 些 基 本 的 分 析 以 消 除 一 些 伪 错<br />

误 。<br />

正 如 RATS 这 个 软 件 的 名 称 所 示 , 该 工 具 只 是 对 源 代 码 进 行 一 个 粗 略 的 分 析 ,<br />

它 不 能 找 到 所 有 的 错 误 同 时 也 不 能 保 证 找 到 的 错 误 都 是 真 正 的 错 误 , 所 以 人 工 的 手<br />

动 审 查 是 必 须 的 , 可 以 将 该 工 具 视 为 有 力 的 辅 助 工 具 。<br />

评 测 分 析<br />

通 过 对 Lighttpd 模 块 的 分 析 , 我 们 得 出 评 测 结 论 。 代 码 的 整 体 风 格 统 一 , 格<br />

式 工 整 , 总 体 质 量 较 好 。 程 序 结 构 复 杂 度 合 理 , 出 现 较 多 的 问 题 主 要 是 代 码 中 潜 在<br />

的 对 NULL 对 象 的 引 用 。 注 释 方 面 , 注 释 丰 富 , 每 个 程 序 文 件 有 基 本 说 明 , 某 些 重<br />

要 的 代 码 有 详 细 解 释 , 给 社 区 参 与 创 造 了 较 好 的 代 码 环 境 。<br />

软 件 测 试<br />

Lighttpd 项 目 没 有 专 门 的 Quality Assurance 组 织 , 但 项 目 中 有 几 位 成 员 主<br />

要 负 责 软 件 的 测 试 。 在 网 站 上 无 专 门 的 用 户 报 告 错 误 或 参 与 测 试 的 页 面 , 错 误 的 报


告 主 要 通 过 Mail List 和 IRC 进 行 。 项 目 提 供 了 一 个 批 处 理 自 动 测 试 环 境 和 一 些 工<br />

具 供 测 试 者 使 用 , 可 以 方 便 的 对 软 件 的 主 要 模 块 进 行 自 动 仿 真 测 试 。<br />

此 外 ,IBM 等 一 些 公 司 也 有 专 门 人 员 帮 助 测 试 和 开 发 。<br />

Lighttpd 易 用 性 研 究<br />

Lighttpd 无 图 形 配 置 、 使 用 、 监 控 环 境 。 软 件 的 主 要 配 置 和 管 理 靠 修 改 配 置<br />

文 件 进 行 , 不 过 , 软 件 提 供 了 一 些 功 能 丰 富 的 命 令 行 工 具 , 这 也 是 服 务 器 软 件 的 一<br />

般 做 法 。 软 件 的 部 署 和 配 置 非 常 灵 活 , 缺 点 是 缺 乏 好 的 监 控 工 具 。<br />

Lighttpd 可 用 性 性 研 究<br />

Lighttpd 不 同 于 Apache 的 多 进 程 模 型 , 它 采 用 了 IO 多 路 复 用 , 还 可 以 在<br />

Linux 平 台 上 使 用 内 核 级 别 的 事 件 驱 动 模 式 , 因 此 ,Lighttpd 具 有 远 远 高 于<br />

Apache 的 性 能 , 能 够 在 单 台 物 理 服 务 器 上 支 撑 超 过 上 万 个 并 发 连 接 请 求 。<br />

虽 然 FastCGI 是 一 种 古 老 的 服 务 器 端 技 术 , 但 是 无 论 在 过 去 还 是 现 在 , 它<br />

仍 然 被 广 泛 地 使 用 , 而 且 被 证 明 是 一 种 经 得 起 考 验 的 技 术 。 最 近 , 随 着 PHP、<br />

Python 和 Ruby 等 互 联 网 动 态 脚 本 语 言 的 崛 起 ,FastCGI 技 术 咸 鱼 翻 身 ,<br />

得 到 更 多 人 的 关 注 了 。 在 这 种 情 况 下 ,Apache 的 FastCGI 支 持 存 在 严 重 的 性 能 缺<br />

陷 , 因 而 Lighttpd 就 显 得 特 别 重 要 。<br />

性 能 能 够 和 Lighttpd 相 提 并 论 的 Web 服 务 器 有 很 多 , 但 是 能 够 支 持 如 此 丰<br />

富 功 能 的 Web 服 务 器 , 还 能 有 这 么 强 大 的 性 能 , 那 就 只 有 Lighttpd 了 。 目 前 ,<br />

Lighttpd 已 经 可 以 支 持 绝 大 多 数 Apache 常 用 的 功 能 , 因 此 只 要 不 是 使 用 了<br />

Apache 比 较 罕 见 的 功 能 , 都 可 以 从 Apache 顺 利 迁 移 到 Lighttpd 上 面 来 。<br />

社 区 及 项 目 组 织


Lighttpd 项 目 是 一 个 典 型 的 服 务 器 端 开 源 软 件 , 项 目 由 几 位 在 HA 应 用 集 群 领<br />

域 活 跃 的 软 件 作 者 主 持 , 项 目 借 助 网 络 , 如 Mail List,IRC, 论 坛 等 工 具 进 行 交<br />

流 , 吸 引 大 量 参 与 者 参 与 开 发 、 测 试 、 书 写 应 用 文 档 。 同 时 , 项 目 也 吸 引 了 一 些 公<br />

司 的 支 持 与 参 与 。 该 项 目 在 实 际 环 境 中 有 大 量 应 用 , 一 些 企 业 也 将 其 作 为 自 己 解 决<br />

方 案 的 一 部 分 , 提 供 了 许 多 应 用 案 例 , 取 得 大 量 反 馈 意 见 , 极 大 的 推 动 了 该 软 件 的<br />

应 用 与 发 展 。<br />

License 问 题<br />

Lighttpd 是 一 套 开 放 源 代 码 的 网 页 服 务 器 , 以 BSD 许 可 证 发 布 。<br />

软 件 成 熟 度 评 估<br />

软 件 成 熟 度 属 性 定 义 与 量 化<br />

ID Class Name Weight<br />

01 技 术 架 构 设 计 4<br />

02 代 码 质 量 4<br />

03 软 件 易 用 性 1<br />

04 软 件 可 用 性 4<br />

05 项 目 建 设 与 管 理 2<br />

06 项 目 的 活 跃 程 度 4<br />

07 项 目 测 试 情 况 2<br />

08 软 件 应 用 支 持 4<br />

09 软 件 法 律 问 题 1<br />

以 下 为 各 属 性 类 的 属 性 定 义 :


ID Class Name Entry Weight Value Memo<br />

01<br />

技 术 架 构 设<br />

计<br />

合 理 性 4 3<br />

02 技 术 架 构 设<br />

计<br />

可 扩 展 性 3 4<br />

03 技 术 架 构 设<br />

计<br />

可 移 植 性 2 5<br />

04<br />

05<br />

06<br />

ID Class Name Entry Weight Value Memo<br />

01 代 码 质 量 代 码 错 误 率 4 5<br />

02 代 码 质 量 代 码 可 读 性 4 4<br />

03 代 码 质 量 代 码 复 杂 度 2 4<br />

04<br />

05<br />

06<br />

ID Class Name Entry Weight Value Memo<br />

01 软 件 易 用 性 易 理 解 性 2 3


02 软 件 易 用 性 易 学 习 性 2 3<br />

03 软 件 易 用 性 易 操 作 性 4 3<br />

04<br />

05<br />

06<br />

ID Class Name Entry Weight Value Memo<br />

01 软 件 可 用 性 完 备 性 3 2<br />

02 软 件 可 用 性 正 确 性 4 4<br />

03 软 件 可 用 性 可 靠 性 4 5<br />

04 软 件 可 用 性 安 全 性 2 4<br />

05<br />

06<br />

ID Class Name Entry Weight Value Memo<br />

01<br />

项 目 建 设 与<br />

管 理<br />

组 织 架 构 2 2<br />

02 项 目 建 设 与<br />

管 理<br />

开 发 管 理 4 3<br />

03 项 目 建 设 与<br />

管 理<br />

网 站 建 设 3 3


04<br />

05<br />

ID Class Name Entry Weight Value Memo<br />

01<br />

项 目 的 活 跃<br />

程 度<br />

版 本 发 布 周<br />

期<br />

2 3<br />

02 项 目 的 活 跃<br />

程 度<br />

软 件 下 载 量 3 4<br />

03 项 目 的 活 跃<br />

程 度<br />

交 流 机 制 4 4<br />

04<br />

05<br />

ID Class Name Entry Weight Value Memo<br />

01<br />

项 目 测 试 情<br />

况<br />

测 试 方 法<br />

( 工 具 )<br />

3 4<br />

02 项 目 测 试 情<br />

况<br />

测 试 人 员 4 4<br />

03 项 目 测 试 情<br />

况<br />

测 试 反 馈 2 3<br />

04<br />

05<br />

ID Class Name Entry Weight Value Memo


01<br />

软 件 应 用 支<br />

持<br />

社 区 支 持 度 4 3<br />

02 软 件 应 用 支<br />

持<br />

企 业 支 持 度 3 3<br />

03 软 件 应 用 支<br />

持<br />

应 用 成 熟 度 3 4<br />

04 软 件 应 用 支<br />

持<br />

书 籍 或 文 档<br />

指 南<br />

2 3 新 版 本 中 文<br />

较 少<br />

05<br />

ID Class Name Entry Weight Value Memo<br />

01<br />

软 件 法 律 问<br />

题<br />

软 件 版 权 协<br />

议<br />

4 5<br />

02 软 件 法 律 问<br />

题<br />

专 利 与 纠 纷 1 4<br />

03<br />

04<br />

05<br />

Lighttpd 软 件 成 熟 度 评 估 结 论<br />

按 照 我 们 的 开 放 源 代 码 软 件 评 估 体 系 计 算 模 型 的 公 司 进 行 计 算 , 最 终 该 软 件 的<br />

评 估 值 为 :305.18。


总 结<br />

通 过 对 开 源 软 件 成 熟 度 评 估 体 系 的 描 述 , 以 及 我 们 应 用 该 评 价 模 型 进 行 的 两 个<br />

试 验 案 例 。 证 明 了 评 估 模 型 的 正 确 性 和 实 用 性 , 为 我 们 今 后 从 事 开 源 软 件 评 估 工 作<br />

奠 定 了 基 础 。<br />

参 考<br />

1 Lighttpd 的 官 方 网 站 :http://www.Lighttpd.net<br />

2 Lighttpd 的 官 方 博 客 :http://blog.Lighttpd.net<br />

3 Lighttpd 的 wiki:http://trac.Lighttpd.net<br />

4 Lighttpd 中 文 官 网 http://www.Lighttpd.com.cn/<br />

附 录<br />

Lighttpd 软 件 代 码 质 量 评 测 报 告 :<br />

RATS 扫 描 结 果 节 选 如 下 :<br />

RATS results.<br />

Severity: High<br />

Issue: getopt<br />

Truncate all input strings to a reasonable length before passing them to this function<br />

File: Lighttpd-1.4.28/src/server.c Line:563[26] while(-1 != (o =<br />

getopt(argc, argv, "f:m:hvVDpt"))) {<br />

Severity: High<br />

Issue: fixed size global buffer<br />

Extra care should be taken to ensure that character arrays that are allocated on the stack<br />

are used safely. They are prime targets for buffer overflow attacks. File: Lighttpd-<br />

1.4.28/src/mod_usertrack.c Line:178[18] unsigned char h[16];<br />

File: Lighttpd-1.4.28/src/mod_usertrack.c Line:180[9]<br />

char hh[32];


File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:1823[9]<br />

char buf[32];<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:1826[9]<br />

char b2[INET6_ADDRSTRLEN + 1];<br />

File: Lighttpd-1.4.28/src/mod_cml_funcs.c Line:43[9]<br />

char hex[33];<br />

File: Lighttpd-1.4.28/src/mod_auth.c Line:287[25]<br />

char hh[33];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:448[5]<br />

char passwd[120], *p;<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:450[14] unsigned<br />

char final[APR_MD5_DIGESTSIZE];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:613[17]<br />

char a1[256];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:629[17]<br />

char sample[120];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:638[17]<br />

char salt[32];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:909[9]<br />

char a1[256];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:910[9]<br />

char a2[256];<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:1169[9]<br />

char hh[32];<br />

File: Lighttpd-1.4.28/src/mod_dirlisting.c Line:642[9] char<br />

sizebuf[sizeof("999.9K")];<br />

File: Lighttpd-1.4.28/src/mod_dirlisting.c Line:643[9]<br />

char datebuf[sizeof("2005-Jan-01 22:23:24")]; File:<br />

Lighttpd-1.4.28/src/mod_dirlisting.c Line:648[9] char<br />

attrval[128];<br />

File: Lighttpd-1.4.28/src/mod_extforward.c Line:349[9]<br />

char b2[INET6_ADDRSTRLEN + 1];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:1297[3]<br />

char errmsg[ERRMSGSIZE];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:1298[3] char<br />

prefix[PREFIXLIMIT+10];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:1582[3]<br />

char *set[LISTSIZE];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:1922[3]<br />

char *alias[MAXRHS]; /* Aliases for each RHS symbol (or NULL) */<br />

File: Lighttpd-1.4.28/src/lemon.c Line:2718[7]<br />

char buf[20];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:2825[3]<br />

char line[LINESIZE];


File: Lighttpd-1.4.28/src/lemon.c Line:2851[3]<br />

char buf[1000];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:2972[2]<br />

char used[MAXRHS]; /* True for each RHS element which is used */<br />

File: Lighttpd-1.4.28/src/lemon.c Line:3200[3]<br />

char line[LINESIZE];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:3594[3]<br />

char line[LINESIZE];<br />

File: Lighttpd-1.4.28/src/lemon.c Line:3595[3] char<br />

pattern[LINESIZE];<br />

File: Lighttpd-1.4.28/src/mod_cgi.c Line:731[9] char<br />

b2[INET6_ADDRSTRLEN + 1];<br />

File: Lighttpd-1.4.28/src/mod_cgi.c Line:769[17]<br />

char buf[32];<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:1453[9]<br />

char buf[32];<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:1456[9]<br />

char b2[INET6_ADDRSTRLEN + 1];<br />

File: Lighttpd-1.4.28/src/http-header-glue.c Line:137[17]<br />

char hbuf[256];<br />

File: Lighttpd-1.4.28/src/http-header-glue.c Line:163[33]<br />

char dst[INET6_ADDRSTRLEN];<br />

File: Lighttpd-1.4.28/src/http-header-glue.c Line:279[49]<br />

char buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")]; File:<br />

Lighttpd-1.4.28/src/http-header-glue.c Line:339[25] char<br />

buf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")]; File:<br />

Lighttpd-1.4.28/src/connections.c Line:1261[17] char<br />

buf[1024];<br />

File: Lighttpd-1.4.28/src/connections.c Line:1621[33]<br />

char buf[1024];<br />

File: Lighttpd-1.4.28/src/request.c Line:474[58]<br />

unsigned char buf[2];<br />

File: Lighttpd-1.4.28/src/mod_ssi.c Line:239[9]<br />

char buf[32];<br />

File: Lighttpd-1.4.28/src/mod_ssi.c Line:244[9] char<br />

b2[INET6_ADDRSTRLEN + 1];<br />

File: Lighttpd-1.4.28/src/mod_ssi.c Line:330[9]<br />

char buf[255];<br />

File: Lighttpd-1.4.28/src/mod_accesslog.c Line:201[41]<br />

char hh[5] = {'\\','x',0,0,0};<br />

File: Lighttpd-1.4.28/src/mod_cml_lua.c Line:401[25]<br />

char timebuf[sizeof("Sat, 23 Jul 2005 21:20:01 GMT")];<br />

File: Lighttpd-1.4.28/src/mod_status.c Line:206[9]<br />

char buf[32];


File: Lighttpd-1.4.28/src/mod_status.c Line:569[9]<br />

char buf[32];<br />

File: Lighttpd-1.4.28/src/mod_webdav.c Line:2318[57]<br />

char uuid[37] /* 36 + \0 */;<br />

File: Lighttpd-1.4.28/src/md5.c Line:177[12]<br />

unsigned char bits[8];<br />

Severity: High<br />

Issue: strcpy<br />

Check to be sure that argument 2 passed to this function call will not copy more data<br />

than can be handled, resulting in a buffer overflow. File: Lighttpd-<br />

1.4.28/src/mod_fastcgi.c Line:877[17] strcpy(fcgi_addr_un.sun_path,<br />

proc->unixsocket->ptr); File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:1666[17]<br />

strcpy(fcgi_addr_un.sun_path, proc->unixsocket->ptr); File: Lighttpd-<br />

1.4.28/src/http_auth.c Line:535[5] strcpy(passwd, APR1_ID);<br />

File: Lighttpd-1.4.28/src/mod_dirlisting.c Line:675[9]<br />

strcpy(path, dir->ptr);<br />

File: Lighttpd-1.4.28/src/network.c Line:309[17]<br />

strcpy(srv_socket->addr.un.sun_path, host); File:<br />

Lighttpd-1.4.28/src/lemon.c Line:2547[3]<br />

strcpy(name,cp);<br />

File: Lighttpd-1.4.28/src/lemon.c Line:3126[7] strcpy(types[hash],stddt);<br />

File: Lighttpd-1.4.28/src/lemon.c Line:3770[5]<br />

strcpy(z,y);<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:673[17]<br />

strcpy(scgi_addr_un.sun_path, proc->socket->ptr); File:<br />

Lighttpd-1.4.28/src/mod_scgi.c Line:1335[17]<br />

strcpy(scgi_addr_un.sun_path, proc->socket->ptr);<br />

Severity: High<br />

Issue: gethostbyname<br />

DNS results can easily be forged by an attacker (or arbitrarily set to large values, etc), and<br />

should not be trusted.<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:908[43]<br />

if (NULL == (he = gethostbyname(host->host->ptr)))<br />

{ File: Lighttpd-1.4.28/src/network.c Line:283[43] if<br />

(NULL == (he = gethostbyname(host))) { File:<br />

Lighttpd-1.4.28/src/mod_scgi.c Line:700[43] if<br />

(NULL == (he = gethostbyname(host->host->ptr))) {<br />

Severity: High<br />

Issue: getenv<br />

Environment variables are highly untrustable input. They may be of any length, and<br />

contain any data. Do not make any assumptions regarding content or length. If at all<br />

possible avoid using them, and if it is necessary, sanitize them and truncate them to a<br />

reasonable length.<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:1025[59]<br />

if (NULL != (ge = getenv(ds->value->ptr))) { File:


Lighttpd-1.4.28/src/lemon.c Line:34[14] extern char<br />

*getenv();<br />

File: Lighttpd-1.4.28/src/lemon.c Line:2769[16] pathlist<br />

= getenv("PATH");<br />

File: Lighttpd-1.4.28/src/configparser.c Line:955[24] if<br />

(NULL != (env = getenv(yymsp[0].minor.yy43->ptr + 4)))<br />

{ File: Lighttpd-1.4.28/src/proc_open.c Line:156[30] if<br />

(NULL == (shell = getenv(SHELLENV)) && File: Lighttpd-<br />

1.4.28/src/proc_open.c Line:157[43]<br />

NULL == (windir = getenv("SystemRoot")) &&<br />

File: Lighttpd-1.4.28/src/proc_open.c Line:158[43]<br />

NULL == (windir = getenv("windir"))) {<br />

File: Lighttpd-1.4.28/src/proc_open.c Line:238[30] if<br />

(NULL == (shell = getenv(SHELLENV))) { File:<br />

Lighttpd-1.4.28/src/mod_cgi.c Line:923[34] if<br />

(NULL != (s = getenv("LD_PRELOAD"))) { File:<br />

Lighttpd-1.4.28/src/mod_cgi.c Line:927[34] if<br />

(NULL != (s = getenv("LD_LIBRARY_PATH"))) { File:<br />

Lighttpd-1.4.28/src/mod_cgi.c Line:932[34] if<br />

(NULL != (s = getenv("SYSTEMROOT"))) { File:<br />

Lighttpd-1.4.28/src/mod_scgi.c Line:804[59] if<br />

(NULL != (ge = getenv(ds->value->ptr))) { File:<br />

Lighttpd-1.4.28/tests/fcgi-auth.c Line:21[27] if (((p =<br />

getenv("QUERY_STRING")) == NULL) || File:<br />

Lighttpd-1.4.28/tests/fcgi-responder.c Line:20[34] if<br />

(NULL != (p = getenv("QUERY_STRING"))) {<br />

File: Lighttpd-1.4.28/tests/fcgi-responder.c Line:44[38] printf("%s",<br />

getenv("PATH_INFO"));<br />

File: Lighttpd-1.4.28/tests/fcgi-responder.c Line:46[38]<br />

printf("%s", getenv("SCRIPT_NAME"));<br />

Severity: High<br />

Issue: strncat<br />

Consider using strlcat() instead.<br />

File: Lighttpd-1.4.28/src/http_auth.c Line:536[5]<br />

strncat(passwd, sp, sl);<br />

Severity: High<br />

Issue: strncat<br />

Check to be sure that argument 1 passed to this function call will not copy more data<br />

than can be handled, resulting in a buffer overflow. File: Lighttpd-<br />

1.4.28/src/http_auth.c Line:536[5]<br />

strncat(passwd, sp, sl);<br />

Severity: High<br />

Issue: vsprintf<br />

Check to be sure that the non-constant format string passed as argument 2 to this<br />

function call does not come from an untrusted source that could have added formatting


characters that the code is not prepared to handle. File: Lighttpd-1.4.28/src/lemon.c<br />

Line:1316[3] vsprintf(errmsg,format,ap);<br />

Severity: High<br />

Issue: vsprintf<br />

Check to be sure that the format string passed as argument 2 to this function call does<br />

not come from an untrusted source that could have added formatting characters that the<br />

code is not prepared to handle. Additionally, the format string could contain `%s' without<br />

precision that could result in a buffer overflow. File: Lighttpd-1.4.28/src/lemon.c<br />

Line:1316[3] vsprintf(errmsg,format,ap);<br />

Severity: High<br />

Issue: strcat<br />

Check to be sure that argument 2 passed to this function call will not copy more data<br />

than can be handled, resulting in a buffer overflow. File: Lighttpd-1.4.28/src/lemon.c<br />

Line:2550[3]<br />

strcat(name,suffix);<br />

Severity: High<br />

Issue: sprintf<br />

Check to be sure that the format string passed as argument 2 to this function call does<br />

not come from an untrusted source that could have added formatting characters that the<br />

code is not prepared to handle. Additionally, the format string could contain `%s' without<br />

precision that could result in a buffer overflow. File: Lighttpd-1.4.28/src/lemon.c<br />

Line:2766[16] if( path ) sprintf(path,"%s/%s",argv0,name); File: Lighttpd-<br />

1.4.28/src/lemon.c Line:2778[9] sprintf(path,"%s/%s",pathlist,name);<br />

File: Lighttpd-1.4.28/src/lemon.c Line:2860[5]<br />

sprintf(buf,"%s.lt",lemp->filename);<br />

File: Lighttpd-1.4.28/src/lemon.c Line:3488[5]<br />

sprintf(line,"\"%s\",",lemp->symbols[i]->name); File:<br />

Lighttpd-1.4.28/src/lemon.c Line:3603[7]<br />

sprintf(pattern,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i);<br />

Severity: High<br />

Issue: syslog<br />

Truncate all input strings to a reasonable length before passing them to this function<br />

File: Lighttpd-1.4.28/src/log.c Line:372[17] syslog(LOG_ERR, "%s",<br />

srv->errorlog_buf->ptr); File: Lighttpd-1.4.28/src/mod_accesslog.c<br />

Line:418[49]<br />

syslog(LOG_INFO, "%*s", (int) s->access_logbuffer->used - 2,<br />

s>access_logbuffer->ptr);<br />

File: Lighttpd-1.4.28/src/mod_accesslog.c Line:596[41]<br />

syslog(LOG_INFO, "%*s", (int) s->access_logbuffer->used - 2,<br />

s>access_logbuffer->ptr);<br />

File: Lighttpd-1.4.28/src/mod_accesslog.c Line:907[33] syslog(LOG_INFO,<br />

"%*s", (int) b->used - 2, b->ptr);<br />

Severity: High<br />

Issue: CreateProcess


Many program execution commands under Windows will search the path for a program<br />

if you do not explicitly specify a full path to the file. This can allow trojans to be<br />

executed instead. Also, be sure to specify a file extension, since otherwise multiple<br />

extensions will be tried by the operating system, providing another opportunity for<br />

trojans.<br />

File: Lighttpd-1.4.28/src/proc_open.c Line:192[18]<br />

procok = CreateProcess(NULL, cmdline->ptr, &security, &security, TRUE,<br />

Severity: High<br />

Issue: CreateProcess<br />

Argument 3 to this function call should be checked to ensure that it does not come from<br />

an untrusted source without first verifying that it contains nothing dangerous. File:<br />

Lighttpd-1.4.28/src/proc_open.c Line:192[18]<br />

procok = CreateProcess(NULL, cmdline->ptr, &security, &security, TRUE,<br />

Severity: High<br />

Issue: fprintf<br />

Check to be sure that the non-constant format string passed as argument 2 to this<br />

function call does not come from an untrusted source that could have added formatting<br />

characters that the code is not prepared to handle. File: Lighttpd-<br />

1.4.28/src/proc_open.c Line:385[17]<br />

fprintf(stdout, "test: echo 123 | " CMD_CAT "\n"); fflush(stdout);<br />

Severity: High<br />

Issue: gethostbyaddr<br />

DNS results can easily be forged by an attacker (or arbitrarily set to large values, etc), and<br />

should not be trusted.<br />

File: Lighttpd-1.4.28/src/http-header-glue.c Line:178[43]<br />

if (NULL == (he = gethostbyaddr((char *)&our_addr.ipv4.sin_addr, sizeof(struct<br />

in_addr), AF_INET))) {<br />

Severity: High<br />

Issue: LoadLibrary<br />

LoadLibrary will search several places for a library if no path is specified, allowing<br />

trojan DLL's to be inserted elsewhere even if the intended DLL is correctly protected<br />

from overwriting. Make sure to specify the full path. File: Lighttpd-1.4.28/src/plugin.c<br />

Line:148[39]<br />

if (NULL == (p->lib = LoadLibrary(srv->tmp_buf->ptr))) {<br />

Severity: High<br />

Issue: gethostbyaddr<br />

DNS results can easily be forged by an attacker (or arbitrarily se t to large values, etc), and<br />

should not be trusted.<br />

File: Lighttpd-1.4.28/tests/LightyTest.pm Line:48[49]<br />

my ($name, $aliases, $addrtype, $net) = gethostbyaddr(inet_aton("127.0.0.1"),<br />

AF_INET);<br />

Severity: Medium<br />

Issue: realloc<br />

Don't use on memory intended to be secure, because the old structure will not be zeroed<br />

out.


File: Lighttpd-1.4.28/src/buffer.c Line:119[26] b->ptr<br />

= realloc(b->ptr, b->size);<br />

File: Lighttpd-1.4.28/src/buffer.c Line:467[26] b->ptr =<br />

realloc(b->ptr, sizeof(*b->ptr) * b->size); File: Lighttpd-<br />

1.4.28/src/mod_rewrite.c Line:90[28] kvb->ptr =<br />

realloc(kvb->ptr, kvb->size * sizeof(*kvb->ptr)); File:<br />

Lighttpd-1.4.28/src/mod_fastcgi.c Line:651[37] ext->exts =<br />

realloc(ext->exts, ext->size * sizeof(*(ext->exts))); File:<br />

Lighttpd-1.4.28/src/mod_fastcgi.c Line:665[29] fe->hosts =<br />

realloc(fe->hosts, fe->size * sizeof(*(fe->hosts))); File:<br />

Lighttpd-1.4.28/src/mod_fastcgi.c Line:784[28] env->ptr =<br />

realloc(env->ptr, env->size * sizeof(*env->ptr)); File:<br />

Lighttpd-1.4.28/src/mod_fastcgi.c Line:809[44] env->ptr =<br />

realloc(env->ptr, env->size * sizeof(*env->ptr)); File:<br />

Lighttpd-1.4.28/src/mod_fastcgi.c Line:828[28] env->ptr =<br />

realloc(env->ptr, env->size * sizeof(*env->ptr)); File:<br />

Lighttpd-1.4.28/src/mod_fastcgi.c Line:839[28] env->ptr =<br />

realloc(env->ptr, env->size * sizeof(*env->ptr)); File:<br />

Lighttpd-1.4.28/src/joblist.c Line:16[39]<br />

srv->joblist->ptr = realloc(srv->joblist->ptr, sizeof(*srv->joblist->ptr) *<br />

srv>joblist->size);<br />

File: Lighttpd-1.4.28/src/joblist.c Line:51[43]<br />

srv->fdwaitqueue->ptr = realloc(srv->fdwaitqueue->ptr,<br />

sizeof(*(srv>fdwaitqueue->ptr)) * srv->fdwaitqueue->size); File: Lighttpd-<br />

1.4.28/src/mod_dirlisting.c Line:109[28] exb->ptr = realloc(exb->ptr, exb->size<br />

* sizeof(*exb->ptr)); File: Lighttpd-1.4.28/src/mod_dirlisting.c Line:763[57]<br />

list->ent = (dirls_entry_t**) realloc(list->ent, sizeof(dirls_entry_t*) * list>size);<br />

File: Lighttpd-1.4.28/src/network.c Line:418[40]<br />

srv->srv_sockets.ptr = realloc(srv->srv_sockets.ptr, srv->srv_sockets.size *<br />

sizeof(server_socket));<br />

File: Lighttpd-1.4.28/src/lemon.c Line:480[21]<br />

p->aLookahead = realloc( p->aLookahead, File:<br />

Lighttpd-1.4.28/src/lemon.c Line:522[18]<br />

p->aAction = realloc( p->aAction,<br />

File: Lighttpd-1.4.28/src/configfile.c Line:986[22]<br />

s1 = realloc(s, len);<br />

File: Lighttpd-1.4.28/src/mod_evhost.c Line:81[42]<br />

s->path_pieces =<br />

* sizeof(*srealloc(s->path_pieces,(s->len+2)<br />

>path_pieces));<br />

File: Lighttpd-1.4.28/src/mod_evhost.c Line:95[34]<br />

s->path_pieces =<br />

* sizeof(*srealloc(s->path_pieces,(s->len+1)<br />

>path_pieces));


File: Lighttpd-1.4.28/src/mod_cgi.c Line:201[26] r->ptr =<br />

realloc(r->ptr, sizeof(*r->ptr) * r->size); File: Lighttpd-<br />

1.4.28/src/mod_cgi.c Line:719[28] env->ptr =<br />

realloc(env->ptr, env->size * sizeof(*env->ptr)); File:<br />

Lighttpd-1.4.28/src/mod_cgi.c Line:1002[35] env.ptr =<br />

realloc(env.ptr, env.size * sizeof(*env.ptr)); File: Lighttpd-<br />

1.4.28/src/mod_scgi.c Line:510[37]<br />

ext->exts = realloc(ext->exts, ext->size * sizeof(*(ext->exts)));<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:524[29] fe->hosts =<br />

realloc(fe->hosts, fe->size * sizeof(*(fe->hosts))); File:<br />

Lighttpd-1.4.28/src/mod_scgi.c Line:636[28] env->ptr =<br />

realloc(env->ptr, env->size * sizeof(*env->ptr)); File:<br />

Lighttpd-1.4.28/src/array.c Line:219[29] a->data =<br />

realloc(a->data, sizeof(*a->data) * a->size); File: Lighttpd-<br />

1.4.28/src/array.c Line:220[29]<br />

a->sorted = realloc(a->sorted, sizeof(*a->sorted) * a->size);<br />

File: Lighttpd-1.4.28/src/keyvalue.c Line:148[27] kvb->kv<br />

= realloc(kvb->kv, kvb->size * sizeof(*kvb->kv)); File:<br />

Lighttpd-1.4.28/src/keyvalue.c Line:199[27] kvb->kv =<br />

realloc(kvb->kv, kvb->size * sizeof(*kvb->kv)); File:<br />

Lighttpd-1.4.28/src/keyvalue.c Line:250[27] kvb->kv =<br />

realloc(kvb->kv, kvb->size * sizeof(*kvb->kv));<br />

File: Lighttpd-1.4.28/src/keyvalue.c Line:339[27]<br />

kvb->kv = realloc(kvb->kv, kvb->size * sizeof(*kvb->kv)); File:<br />

Lighttpd-1.4.28/src/mod_magnet_cache.c Line:102[38] cache->ptr<br />

= realloc(cache->ptr, cache->size * sizeof(*(cache->ptr))); File:<br />

Lighttpd-1.4.28/src/connections.c Line:56[30]<br />

conns->ptr = realloc(conns->ptr, sizeof(*conns->ptr) * conns->size); File:<br />

Lighttpd-1.4.28/src/plugin.c Line:87[38]<br />

srv->plugins.ptr = realloc(srv->plugins.ptr, srv->plugins.size * sizeof(*ps)); File:<br />

Lighttpd-1.4.28/src/mod_accesslog.c Line:234[55]<br />

fields->ptr = realloc(fields->ptr, fields->size * sizeof(format_field * )); File:<br />

Lighttpd-1.4.28/src/mod_accesslog.c Line:254[47]<br />

fields->ptr = realloc(fields->ptr, fields->size * sizeof(format_field * )); File:<br />

Lighttpd-1.4.28/src/mod_accesslog.c Line:386[39]<br />

fields->ptr = realloc(fields->ptr, fields->size * sizeof(format_field * ));<br />

File: Lighttpd-1.4.28/src/stat_cache.c Line:519[36] ctrl.ptr =<br />

realloc(ctrl.ptr, ctrl.size * sizeof(*ctrl.ptr));<br />

File: Lighttpd-1.4.28/src/mod_webdav.c Line:1305[90]<br />

req_props->ptr = realloc(req_props->ptr, sizeof(*(req_props->ptr)) *<br />

req_props->size);<br />

File: Lighttpd-1.4.28/src/fdevent_poll.c Line:42[42]<br />

ev->unused.ptr = realloc(ev->unused.ptr, sizeof(*(ev->unused.ptr)) *<br />

ev>unused.size);<br />

File: Lighttpd-1.4.28/src/fdevent_poll.c Line:100[39]


ev->pollfds = realloc(ev->pollfds, sizeof(*ev->pollfds) * ev->size);<br />

Severity: Medium<br />

Issue: signal<br />

When setting signal handlers, do not use the same function to handle multiple signals.<br />

There exists the possibility a race condition will result if 2 or more different signals are<br />

sent to the process at nearly the same time. Also, when writing signal handlers, it is best<br />

to do as little as possible in them. The best strategy is to use the signal handler to set a<br />

flag, that another part of the program tests and performs the appropriate action(s) when<br />

it is set. See also: http://razor.bindview.com/publish/papers/signals.txt<br />

File: Lighttpd-1.4.28/src/server.c Line:150[9] signal(SIGTTOU,<br />

SIG_IGN);<br />

File: Lighttpd-1.4.28/src/server.c Line:153[9] signal(SIGTTIN,<br />

SIG_IGN);<br />

File: Lighttpd-1.4.28/src/server.c Line:156[9] signal(SIGTSTP,<br />

SIG_IGN);<br />

File: Lighttpd-1.4.28/src/server.c Line:162[9] signal(SIGHUP,<br />

SIG_IGN);<br />

File: Lighttpd-1.4.28/src/server.c Line:1012[9] signal(SIGPIPE,<br />

SIG_IGN);<br />

File: Lighttpd-1.4.28/src/server.c Line:1013[9] signal(SIGUSR1,<br />

SIG_IGN);<br />

File: Lighttpd-1.4.28/src/server.c Line:1014[9]<br />

signal(SIGALRM, signal_handler);<br />

File: Lighttpd-1.4.28/src/server.c Line:1015[9] signal(SIGTERM,<br />

signal_handler);<br />

File: Lighttpd-1.4.28/src/server.c Line:1016[9] signal(SIGHUP,<br />

signal_handler);<br />

File: Lighttpd-1.4.28/src/server.c Line:1017[9] signal(SIGCHLD,<br />

signal_handler);<br />

File: Lighttpd-1.4.28/src/server.c Line:1018[9] signal(SIGINT,<br />

signal_handler);<br />

File: Lighttpd-1.4.28/src/server.c Line:1022[9] signal(SIGALRM,<br />

signal_handler);<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:377[9]<br />

signal(SIGTTOU, SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:380[9]<br />

signal(SIGTTIN, SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:383[9]<br />

signal(SIGTSTP, SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:385[9]<br />

signal(SIGHUP, SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:386[9]<br />

signal(SIGPIPE, SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:387[9]<br />

signal(SIGUSR1, SIG_DFL);


File: Lighttpd-1.4.28/src/mod_scgi.c Line:337[9] signal(SIGTTOU,<br />

SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:340[9] signal(SIGTTIN,<br />

SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:343[9] signal(SIGTSTP,<br />

SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:345[9] signal(SIGHUP,<br />

SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:346[9] signal(SIGPIPE,<br />

SIG_DFL);<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:347[9]<br />

signal(SIGUSR1, SIG_DFL);<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 661 (open) , 680 (open) File: Lighttpd-1.4.28/src/server.c<br />

Line:669[34]<br />

if (0 != stat(srv->srvconf.pid_file->ptr, &st)) {<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 128 (opendir)<br />

File: Lighttpd-1.4.28/src/mod_cml_funcs.c Line:86[19]<br />

if (-1 == stat(lua_tostring(L, 1), &st)) {<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 678 (opendir)<br />

File: Lighttpd-1.4.28/src/mod_dirlisting.c Line:754[21]<br />

if (stat(path, &st) != 0)<br />

Severity: Medium<br />

Issue: kill<br />

Avoid constructing the list of process ids to kill with any strings that contain user inputted<br />

data. Users may be able to manipulate the pid values in such a way as to cause arbitrary<br />

signals to be sent to processes, possibly leading to exploits or DoS attacks.<br />

File: Lighttpd-1.4.28/tests/LightyTest.pm Line:76[17] kill('TERM',<br />

$pid) or return -1;<br />

File: Lighttpd-1.4.28/tests/LightyTest.pm Line:102[25]<br />

kill('TERM', $child);<br />

File: Lighttpd-1.4.28/tests/LightyTest.pm Line:399[9]<br />

kill(2, $pid);<br />

Severity: Medium


Issue: bind<br />

The second argument specifiying the packed address to bind to, should not be derived<br />

from user input. If the address is derived from user input, it is possible for a malicious<br />

user to cause the socket to be bound to an address of their choice. File: Lighttpd-<br />

1.4.28/tests/LightyTest.pm Line:383[17]<br />

bind(SOCK, sockaddr_in($port, $iaddr)) || die "bind: $!";<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 33 (open)<br />

File: Lighttpd-1.4.28/src/stream.c Line:26[19]<br />

if (-1 == stat(fn->ptr, &st)) {<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 497 (open)<br />

File: Lighttpd-1.4.28/src/stat_cache.c Line:484[19]<br />

if (-1 == stat(name->ptr, &st)) {<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 613 (rmdir)<br />

File: Lighttpd-1.4.28/src/mod_webdav.c Line:607[35]<br />

if (-1 == stat(d.path->ptr, &st)) {<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 1399 (opendir) , 1510 (mkdir) , 1579 (rmdir) , 1594<br />

(unlink) , 1668 (open) , 1692 (open) , 1694 (open)<br />

File: Lighttpd-1.4.28/src/mod_webdav.c Line:1543[27]<br />

if (-1 == stat(con->physical.path->ptr, &st)) {<br />

Severity: Medium<br />

Issue: stat<br />

A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the first<br />

line where a check has occured. The following line(s) contain uses that may<br />

match up with this check: 1906 (mkdir) , 1916 (unlink) , 1917 (mkdir) File:<br />

Lighttpd-1.4.28/src/mod_webdav.c Line:1905[35]<br />

if (-1 == stat(p->physical.path->ptr, &st)) {<br />

Severity: Medium<br />

Issue: stat


A potential TOCTOU (Time Of Check, Time Of Use) vulnerability exists. This is the<br />

first line where a check has occured. The following line(s) contain uses that may match<br />

up with this check: 1934 (rmdir)<br />

File: Lighttpd-1.4.28/src/mod_webdav.c Line:2055[27]<br />

if (-1 == stat(con->physical.path->ptr, &st)) {<br />

Severity: Medium<br />

Issue: ERR_error_string<br />

Use ERR_error_string_n() instead<br />

File: Lighttpd-1.4.28/src/network_openssl.c Line:102[73]<br />

ERR_error_string(err, NULL));<br />

File: Lighttpd-1.4.28/src/network_openssl.c Line:134[65]<br />

ERR_error_string(err, NULL));<br />

File: Lighttpd-1.4.28/src/network_openssl.c Line:206[81]<br />

ERR_error_string(err, NULL));<br />

File: Lighttpd-1.4.28/src/network_openssl.c Line:238[73]<br />

ERR_error_string(err, NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:266[52] r,<br />

ERR_error_string(ssl_err, NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:300[52]<br />

r, ERR_error_string(ssl_err, NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:1349[49]<br />

ERR_error_string(ERR_get_error(), NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:1362[49]<br />

ERR_error_string(ERR_get_error(), NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:1580[65]<br />

ERR_error_string(ERR_get_error(), NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:1707[81]<br />

ERR_error_string(err, NULL));<br />

File: Lighttpd-1.4.28/src/connections.c Line:1720[73]<br />

ERR_error_string(err, NULL));<br />

Severity: Medium<br />

Issue: read<br />

Check buffer boundaries if calling this function in a loop and make sure you are not in<br />

danger of writing past the allocated space.<br />

File: Lighttpd-1.4.28/src/network_openssl.c Line:182[53]<br />

if (-1 == (toSend = read(ifd, local_send_buffer, toSend)))<br />

{ File: Lighttpd-1.4.28/src/connections.c Line:363[15]<br />

len = read(con->fd, b->ptr + read_offset, b->size - 1 - read_offset);<br />

File: Lighttpd-1.4.28/src/connections.c Line:1263[23]<br />

len = read(con->fd, buf, sizeof(buf));<br />

File: Lighttpd-1.4.28/src/connections.c Line:1623[39]<br />

len = read(con->fd, buf, sizeof(buf));<br />

File: Lighttpd-1.4.28/src/mod_ssi.c Line:808[66]<br />

if ((r = read(from_exec_fds[0], b->ptr, b->size - 1)) < 0) {


Severity: Medium<br />

Issue: read<br />

Check buffer boundaries if calling this function in a loop and make sure you are not in<br />

danger of writing past the allocated space.<br />

File: Lighttpd-1.4.28/src/mod_scgi.c Line:1793[32]<br />

if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1))) {<br />

File: Lighttpd-1.4.28/src/mod_rrdtool.c Line:217[23]<br />

res = read(fd, buf, count);<br />

Severity: Medium<br />

Issue: read<br />

Check buffer boundaries if calling this function in a loop and make sure you are not in<br />

danger of writing past the allocated space.<br />

File: Lighttpd-1.4.28/src/proc_open.c Line:282[26] if ((s =<br />

read(fd, (void *)(b->ptr + b->used), 512 - 1)) tmp_buf->ptr, toSend))) { File:<br />

Lighttpd-1.4.28/src/mod_cgi.c Line:346[32]<br />

if (-1 == (n = read(hctx->fd, hctx->response->ptr, hctx->response->size - 1)))<br />

{<br />

Severity: Medium<br />

Issue: read<br />

Check buffer boundaries if calling this function in a loop and make sure you are not in<br />

danger of writing past the allocated space.<br />

File: Lighttpd-1.4.28/src/mod_fastcgi.c Line:2546[32] if<br />

(-1 == (r = read(hctx->fd, b->ptr, toread))) {<br />

File: Lighttpd-1.4.28/src/mod_proxy.c Line:678[32]<br />

if (-1 == (r = read(hctx->fd, hctx->response->ptr + hctx->response->used - 1, b)))<br />

{<br />

Severity: Medium<br />

Issue: crypt<br />

Standard random number generators should not be used to generate randomness used<br />

for security reasons. For security sensitive randomness a crytographic randomness<br />

generator that provides sufficient entropy should be used. File: Lighttpd-<br />

1.4.28/src/http_auth.c Line:680[27]<br />

crypted = crypt(pw, salt);<br />

Severity: Medium<br />

Issue: ERR_error_string<br />

Use ERR_error_string_n() instead<br />

File: Lighttpd-1.4.28/src/network.c Line:535[41]<br />

ERR_error_string(ERR_get_error(), NULL));<br />

File: Lighttpd-1.4.28/src/network.c Line:552[49]<br />

ERR_error_string(ERR_get_error(), NULL));<br />

File: Lighttpd-1.4.28/src/network.c Line:560[49]<br />

ERR_error_string(ERR_get_error(), NULL), s->ssl_ca_file);


File: Lighttpd-1.4.28/src/network.c Line:567[57]<br />

ERR_error_string(ERR_get_error(), NULL), s->ssl_ca_file);<br />

File: Lighttpd-1.4.28/src/network.c Line:571[49]<br />

ERR_error_string(ERR_get_error(), NULL));<br />

File: Lighttpd-1.4.28/src/network.c Line:591[41]<br />

ERR_error_string(ERR_get_error(), NULL), s->ssl_pemfile);<br />

File: Lighttpd-1.4.28/src/network.c Line:597[41]<br />

ERR_error_string(ERR_get_error(), NULL), s->ssl_pemfile);<br />

File: Lighttpd-1.4.28/src/network.c Line:604[41]<br />

ERR_error_string(ERR_get_error(), NULL),<br />

Inputs detected at the following points<br />

Total lines analyzed: 54350<br />

Total time 0.073244 seconds<br />

742040 lines per second

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!