2 Star 0 Fork 22

惊奇脆片饼干/ntp

forked from src-openEuler/ntp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-process_control-should-bail-earlier-on-short-packets.patch 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
Subject: [PATCH] process_control() should bail earlier on short packets
---
ntpd/ntp_control.c | 19 +-
1 files changed, 21 insertions(+), 28 deletions(-)
create mode 100644 ntpd/ntp_control.c.orig
diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c
index 48cd908..5984c8c 100644
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -1187,15 +1187,21 @@ process_control(
pkt = (struct ntp_control *)&rbufp->recv_pkt;
/*
- * If the length is less than required for the header, or
- * it is a response or a fragment, ignore this.
+ * If the length is less than required for the header,
+ * ignore it.
*/
- if (rbufp->recv_length < (int)CTL_HEADER_LEN
- || (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op
+ if (rbufp->recv_length < (int)CTL_HEADER_LEN) {
+ DPRINTF(1, ("Short control packet\n"));
+ numctltooshort++;
+ return;
+ }
+
+ /*
+ * If this packet is a response or a fragment, ignore it.
+ */
+ if ( (CTL_RESPONSE | CTL_MORE | CTL_ERROR) & pkt->r_m_e_op
|| pkt->offset != 0) {
DPRINTF(1, ("invalid format in control packet\n"));
- if (rbufp->recv_length < (int)CTL_HEADER_LEN)
- numctltooshort++;
if (CTL_RESPONSE & pkt->r_m_e_op)
numctlinputresp++;
if (CTL_MORE & pkt->r_m_e_op)
@@ -1206,6 +1212,7 @@ process_control(
numctlbadoffset++;
return;
}
+
res_version = PKT_VERSION(pkt->li_vn_mode);
if (res_version > NTP_VERSION || res_version < NTP_OLDVERSION) {
DPRINTF(1, ("unknown version %d in control packet\n",
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dogsheng/ntp.git
git@gitee.com:dogsheng/ntp.git
dogsheng
ntp
ntp
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385