[X2Go-Commits] [libx2goclient] 01/03: src/x2goclient-openssh-version.c: only search within the first line.

git-admin at x2go.org git-admin at x2go.org
Sat May 16 00:00:03 CEST 2020


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository libx2goclient.

commit 34afcd712b6f1c57764384023e67522afdcd551a
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Fri May 15 23:32:17 2020 +0200

    src/x2goclient-openssh-version.c: only search within the first line.
---
 src/x2goclient-openssh-version.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/x2goclient-openssh-version.c b/src/x2goclient-openssh-version.c
index 7f4479a..92cb853 100644
--- a/src/x2goclient-openssh-version.c
+++ b/src/x2goclient-openssh-version.c
@@ -131,13 +131,23 @@ _Bool x2goclient_openssh_version_parse (X2GoClientOpenSSHVersion *openssh_versio
 
   X2GoClientOpenSSHVersion *struct_work_copy = x2goclient_openssh_version_copy (openssh_version);
 
+  const gchar *newline = NULL;
+  gchar *version_string_work = NULL;
+  if (newline = g_strstr_len (version_string, -1, "\n")) {
+    g_log (NULL, G_LOG_LEVEL_INFO, "Passed version string contains at least one newline, truncating string to first line.");
+    version_string_work = g_strndup (version_string, newline - version_string);
+  }
+  else {
+    version_string_work = g_strdup (version_string);
+  }
+
   /*
    * We expect the version string to have a more-or-less fixed format, such as:
    *
    * OpenSSH_<major>.<minor>p<patch><additional data>[,<whitespace><end of line>]
    */
   /* Start with the fixed preamble. */
-  const gchar *tmp = version_string;
+  const gchar *tmp = version_string_work;
   if (!(g_str_has_prefix (tmp, "OpenSSH_"))) {
     g_set_error_literal (gerr, ERROR_QUARK, X2GOCLIENT_OPENSSH_VERSION_ERROR_INVALID_PREAMBLE, "Preamble in version string does not match expected value 'OpenSSH_'.");
 
@@ -347,5 +357,8 @@ _Bool x2goclient_openssh_version_parse (X2GoClientOpenSSHVersion *openssh_versio
   x2goclient_openssh_version_free (struct_work_copy);
   struct_work_copy = NULL;
 
+  g_free (version_string_work);
+  version_string_work = NULL;
+
   return (ret);
 }

--
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