diff options
author | Pavel Roskin <plroskin@gmail.com> | 2016-06-21 16:30:17 -0700 |
---|---|---|
committer | Pavel Roskin <plroskin@gmail.com> | 2016-07-08 04:15:41 +0000 |
commit | 1ded8ec43726e9b65048be2c9f4fb044dbc0ec9d (patch) | |
tree | 57685d599781c19803c7fddc30c779b9fdfd88de | |
parent | f908528a004812c36a27a6705f8d2453cc9084c4 (diff) | |
download | xrdp-proprietary-1ded8ec43726e9b65048be2c9f4fb044dbc0ec9d.tar.gz xrdp-proprietary-1ded8ec43726e9b65048be2c9f4fb044dbc0ec9d.zip |
Remove unused string support in scp_session_set_addr()
Using the same argument for binary and text data is not a good idea. If
string support is ever needed, it should be a separate function.
Remove SCP_ADDRESS_TYPE_IPV4_BIN and SCP_ADDRESS_TYPE_IPV6_BIN, use
SCP_ADDRESS_TYPE_IPV4 and SCP_ADDRESS_TYPE_IPV6, which simplifies the
code.
-rw-r--r-- | sesman/libscp/libscp_session.c | 36 | ||||
-rw-r--r-- | sesman/libscp/libscp_session.h | 2 | ||||
-rw-r--r-- | sesman/libscp/libscp_types.h | 4 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1s.c | 4 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1s_mng.c | 4 |
5 files changed, 6 insertions, 44 deletions
diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index a1859aa5..91f93b54 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -396,49 +396,15 @@ scp_session_set_display(struct SCP_SESSION *s, SCP_DISPLAY display) /*******************************************************************/ int -scp_session_set_addr(struct SCP_SESSION *s, int type, void *addr) +scp_session_set_addr(struct SCP_SESSION *s, int type, const void *addr) { - struct in_addr ip4; -#ifdef IN6ADDR_ANY_INIT - struct in6_addr ip6; -#endif - int ret; - switch (type) { case SCP_ADDRESS_TYPE_IPV4: - /* convert from char to 32bit*/ - ret = inet_pton(AF_INET, addr, &ip4); - - if (ret == 0) - { - log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); - inet_pton(AF_INET, "127.0.0.1", &ip4); - g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4); - return 1; - } - - g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4); - break; - case SCP_ADDRESS_TYPE_IPV4_BIN: g_memcpy(&(s->ipv4addr), addr, 4); break; #ifdef IN6ADDR_ANY_INIT case SCP_ADDRESS_TYPE_IPV6: - /* convert from char to 128bit*/ - ret = inet_pton(AF_INET6, addr, &ip6); - - if (ret == 0) - { - log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); - inet_pton(AF_INET, "::1", &ip6); - g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16); - return 1; - } - - g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16); - break; - case SCP_ADDRESS_TYPE_IPV6_BIN: g_memcpy(s->ipv6addr, addr, 16); break; #endif diff --git a/sesman/libscp/libscp_session.h b/sesman/libscp/libscp_session.h index b545af9e..4a9e9d70 100644 --- a/sesman/libscp/libscp_session.h +++ b/sesman/libscp/libscp_session.h @@ -83,7 +83,7 @@ int scp_session_set_hostname(struct SCP_SESSION* s, char* str); int -scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr); +scp_session_set_addr(struct SCP_SESSION* s, int type, const void* addr); int scp_session_set_display(struct SCP_SESSION* s, SCP_DISPLAY display); diff --git a/sesman/libscp/libscp_types.h b/sesman/libscp/libscp_types.h index de851867..78d53e56 100644 --- a/sesman/libscp/libscp_types.h +++ b/sesman/libscp/libscp_types.h @@ -51,10 +51,6 @@ #define SCP_ADDRESS_TYPE_IPV4 0x00 #define SCP_ADDRESS_TYPE_IPV6 0x01 -/* used in scp_session_set_addr() */ -#define SCP_ADDRESS_TYPE_IPV4_BIN 0x80 -#define SCP_ADDRESS_TYPE_IPV6_BIN 0x81 - #define SCP_COMMAND_SET_DEFAULT 0x0000 #define SCP_COMMAND_SET_MANAGE 0x0001 #define SCP_COMMAND_SET_RSR 0x0002 diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c index b7d422c7..6cdf0b00 100644 --- a/sesman/libscp/libscp_v1s.c +++ b/sesman/libscp/libscp_v1s.c @@ -150,12 +150,12 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION *c, struct SCP_SES if (sz == SCP_ADDRESS_TYPE_IPV4) { in_uint32_be(c->in_s, size); - scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV4_BIN, &size); + scp_session_set_addr(session, sz, &size); } else if (sz == SCP_ADDRESS_TYPE_IPV6) { in_uint8a(c->in_s, buf, 16); - scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV6_BIN, buf); + scp_session_set_addr(session, sz, buf); } buf[256] = '\0'; diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c index 24553429..e48fc86b 100644 --- a/sesman/libscp/libscp_v1s_mng.c +++ b/sesman/libscp/libscp_v1s_mng.c @@ -90,12 +90,12 @@ scp_v1s_mng_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s) if (sz == SCP_ADDRESS_TYPE_IPV4) { in_uint32_be(c->in_s, ipaddr); - scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV4_BIN, &ipaddr); + scp_session_set_addr(session, sz, &ipaddr); } else if (sz == SCP_ADDRESS_TYPE_IPV6) { in_uint8a(c->in_s, buf, 16); - scp_session_set_addr(session, SCP_ADDRESS_TYPE_IPV6_BIN, buf); + scp_session_set_addr(session, sz, buf); } /* reading hostname */ |