[X2Go-Commits] [libx2goclient] 09/11: src/x2goclient-network-ssh.c: fix (some) sockspec parsing truncation due to an off-by-one error when looking for the port separator colon or enclosing brackets.
git-admin at x2go.org
git-admin at x2go.org
Sat Aug 31 23:29:03 CEST 2019
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository libx2goclient.
commit 143bbbebbb9aa91b74cd1caceb35b46f3dc4a411
Author: Mihai Moldovan <ionic at ionic.de>
Date: Sat Aug 31 22:19:34 2019 +0200
src/x2goclient-network-ssh.c: fix (some) sockspec parsing truncation due to an off-by-one error when looking for the port separator colon or enclosing brackets.
IPv6 spec parsing still fails, so more work required here.
---
src/x2goclient-network-ssh.c | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/src/x2goclient-network-ssh.c b/src/x2goclient-network-ssh.c
index 94374c3..87825f9 100644
--- a/src/x2goclient-network-ssh.c
+++ b/src/x2goclient-network-ssh.c
@@ -284,7 +284,6 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
* See if that checks out.
*/
++tmp_start;
- --tmp_end;
address = g_string_new_len (tmp_start, tmp_end - tmp_start);
}
@@ -306,8 +305,6 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
tmp_end = g_strstr_len (tmp_start, -1, ":");
if (tmp_end) {
- --tmp_end;
-
address = g_string_new_len (tmp_start, tmp_end - tmp_start);
}
else {
@@ -333,7 +330,6 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
GString *filter_work = NULL;
if (filter_end) {
- --filter_end;
filter_work = g_string_new_len (filter_start, filter_end - filter_start);
}
else {
@@ -359,19 +355,18 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_ip (const GString *
/*
* Specification in brackets, so check if there's a port specifier.
*
- * tmp_end points to the last part of the address, so tmp_end + 1
- * will point to the terminating bracket. tmp_end + 2 can, in the
- * worst case, point to the terminating NULL character, which is
+ * tmp_end points to the terminating bracket. tmp_end + 1 can, in
+ * the worst case, point to the terminating NULL character, which is
* fine.
*/
- portspec = g_string_new (tmp_end + 2);
+ portspec = g_string_new (tmp_end + 1);
}
else {
/*
* IPv4 addresses are not encapsulated in brackets, so the offset is
* lower by one.
*/
- portspec = g_string_new (tmp_end + 1);
+ portspec = g_string_new (tmp_end);
}
GError *tmp_err = NULL;
@@ -432,8 +427,6 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_alias (const GStrin
tmp_end = g_strstr_len (tmp_start, -1, ":");
if (tmp_end) {
- --tmp_end;
-
address = g_string_new_len (tmp_start, tmp_end - tmp_start);
}
else {
@@ -455,10 +448,10 @@ static GSocketAddress* x2goclient_network_ssh_parse_sockspec_alias (const GStrin
if (!(int_err)) {
if (tmp_end) {
/*
- * No encapsulation whatsoever, so the colon must be at the next
+ * No encapsulation whatsoever, so the colon must be at the current
* position.
*/
- GString *portspec = g_string_new (tmp_end + 1);
+ GString *portspec = g_string_new (tmp_end);
GError *tmp_err = NULL;
port = x2goclient_network_ssh_parse_sockspec_port (portspec, &tmp_err);
--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/libx2goclient.git
More information about the x2go-commits
mailing list