knot: backport segfault fix for knsupdate.

This commit is contained in:
Leah Neukirchen 2022-11-11 16:01:15 +01:00
parent 42602f3661
commit 0aaa7a9ed4
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 8a6645dab63d8fa7932c7d8f747fe33e8cc97e84 Mon Sep 17 00:00:00 2001
From: Daniel Salzman <daniel.salzman@nic.cz>
Date: Sun, 6 Nov 2022 13:43:27 +0100
Subject: [PATCH] knsupdate: fix segfault due to NULL pointer access when
sending an update
---
src/utils/common/netio.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/utils/common/netio.c b/src/utils/common/netio.c
index 2fdb142b4..56017b1b9 100644
--- a/src/utils/common/netio.c
+++ b/src/utils/common/netio.c
@@ -222,6 +222,12 @@ int net_init(const srv_info_t *local,
net->proxy.src = proxy_src;
net->proxy.dst = proxy_dst;
+ if ((bool)(proxy_src == NULL) != (bool)(proxy_dst == NULL) ||
+ (proxy_src != NULL && proxy_src->sa_family != proxy_dst->sa_family)) {
+ net_clean(net);
+ return KNOT_EINVAL;
+ }
+
// Prepare for TLS.
if (tls_params != NULL && tls_params->enable) {
int ret = 0;
@@ -584,7 +590,7 @@ int net_send(const net_t *net, const uint8_t *buf, const size_t buf_len)
.msg_iovlen = 1
};
- if (net->proxy.src->sa_family && net->proxy.dst->sa_family) {
+ if (net->proxy.src != NULL && net->proxy.src->sa_family != 0) {
int ret = proxyv2_write_header(proxy_buf, sizeof(proxy_buf),
SOCK_DGRAM, net->proxy.src,
net->proxy.dst);
@@ -638,7 +644,7 @@ int net_send(const net_t *net, const uint8_t *buf, const size_t buf_len)
.msg_iovlen = 2
};
- if (net->proxy.src->sa_family && net->proxy.dst->sa_family) {
+ if (net->proxy.src != NULL && net->proxy.src->sa_family != 0) {
int ret = proxyv2_write_header(proxy_buf, sizeof(proxy_buf),
SOCK_STREAM, net->proxy.src,
net->proxy.dst);
--
GitLab

View File

@ -1,7 +1,7 @@
# Template file for 'knot'
pkgname=knot
version=3.2.2
revision=1
revision=2
build_style=gnu-configure
configure_args="
--disable-silent-rules