加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2020-26961-1.patch 2.07 KB
一键复制 编辑 原始数据 按行查看 历史
wangxiao65 提交于 2021-01-07 15:15 . fix cves
# HG changeset patch
# User Valentin Gosu <valentin.gosu@gmail.com>
# Date 1604497734 0
# Wed Nov 04 13:48:54 2020 +0000
# Node ID 179e399ac08119ef3da61766c73f265679a6cf51
# Parent 6810172b5a5861dbf847848d0a34f13787c1a6ba
Bug 1672528 - Check IPv4-mapped IPv6 addresses for being local r=dragana,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D95414
diff -r 6810172b5a58 -r 179e399ac081 netwerk/dns/DNS.cpp
--- a/netwerk/dns/DNS.cpp Wed Nov 04 17:16:26 2020 +0000
+++ b/netwerk/dns/DNS.cpp Wed Nov 04 13:48:54 2020 +0000
@@ -183,27 +183,37 @@ bool IsIPAddrV4Mapped(const NetAddr* add
return false;
}
+static bool isLocalIPv4(uint32_t networkEndianIP) {
+ uint32_t addr32 = ntohl(networkEndianIP);
+ if (addr32 >> 24 == 0x0A || // 10/8 prefix (RFC 1918).
+ addr32 >> 20 == 0xAC1 || // 172.16/12 prefix (RFC 1918).
+ addr32 >> 16 == 0xC0A8 || // 192.168/16 prefix (RFC 1918).
+ addr32 >> 16 == 0xA9FE) { // 169.254/16 prefix (Link Local).
+ return true;
+ }
+ return false;
+}
+
bool IsIPAddrLocal(const NetAddr* addr) {
MOZ_ASSERT(addr);
// IPv4 RFC1918 and Link Local Addresses.
if (addr->raw.family == AF_INET) {
- uint32_t addr32 = ntohl(addr->inet.ip);
- if (addr32 >> 24 == 0x0A || // 10/8 prefix (RFC 1918).
- addr32 >> 20 == 0xAC1 || // 172.16/12 prefix (RFC 1918).
- addr32 >> 16 == 0xC0A8 || // 192.168/16 prefix (RFC 1918).
- addr32 >> 16 == 0xA9FE) { // 169.254/16 prefix (Link Local).
- return true;
- }
+ return isLocalIPv4(addr->inet.ip);
}
// IPv6 Unique and Link Local Addresses.
+ // or mapped IPv4 address
if (addr->raw.family == AF_INET6) {
uint16_t addr16 = ntohs(addr->inet6.ip.u16[0]);
if (addr16 >> 9 == 0xfc >> 1 || // fc00::/7 Unique Local Address.
addr16 >> 6 == 0xfe80 >> 6) { // fe80::/10 Link Local Address.
return true;
}
+ if (IPv6ADDR_IS_V4MAPPED(&addr->inet6.ip)) {
+ return isLocalIPv4(IPv6ADDR_V4MAPPED_TO_IPADDR(&addr->inet6.ip));
+ }
}
+
// Not an IPv4/6 local address.
return false;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化