39 lines
1.5 KiB
Diff
39 lines
1.5 KiB
Diff
|
|
From b236ece1136ede77435f7af80b60a05e175678c6 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Vadim Penzin <vadimp@users.sf.net>
|
||
|
|
Date: Tue, 28 Oct 2014 22:25:41 -0400
|
||
|
|
Subject: [PATCH 04/28] Fixed the wrong type used while comparing IPv4
|
||
|
|
addresses
|
||
|
|
|
||
|
|
src/tcs/rpc/tcstp/rpc.c:access_control() checks if peer's address is
|
||
|
|
INADDR_LOOPBACK. There are two issues with the current code:
|
||
|
|
|
||
|
|
1. For correctness, in_addr_t should be used instead of uint32_t.
|
||
|
|
2. memcmp(3) is passed sizeof(struct sockaddr_in) that is larger than
|
||
|
|
sizeof(in_add_r) (or sizeof(uin32_t) for that matter), so the call
|
||
|
|
always fails.
|
||
|
|
|
||
|
|
From https://sourceforge.net/p/trousers/trousers/ci/b236ece1136ede77435f7af80b60a05e175678c6/
|
||
|
|
---
|
||
|
|
src/tcs/rpc/tcstp/rpc.c | 4 ++--
|
||
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/tcs/rpc/tcstp/rpc.c b/src/tcs/rpc/tcstp/rpc.c
|
||
|
|
index a235a84..1573a8a 100644
|
||
|
|
--- a/src/tcs/rpc/tcstp/rpc.c
|
||
|
|
+++ b/src/tcs/rpc/tcstp/rpc.c
|
||
|
|
@@ -536,9 +536,9 @@ access_control(struct tcsd_thread_data *thread_data)
|
||
|
|
// Check if it's localhost for both inet protocols
|
||
|
|
if (sa->sa_family == AF_INET) {
|
||
|
|
struct sockaddr_in *sa_in = (struct sockaddr_in *)sa;
|
||
|
|
- uint32_t nloopaddr = htonl(INADDR_LOOPBACK);
|
||
|
|
+ in_addr_t nloopaddr = htonl(INADDR_LOOPBACK);
|
||
|
|
if (memcmp(&sa_in->sin_addr.s_addr, &nloopaddr,
|
||
|
|
- sizeof(struct sockaddr_in)) == 0)
|
||
|
|
+ sizeof(in_addr_t)) == 0)
|
||
|
|
is_localhost = 1;
|
||
|
|
else if (sa->sa_family == AF_INET6) {
|
||
|
|
struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *)sa;
|
||
|
|
--
|
||
|
|
1.8.3.1
|
||
|
|
|