From 5568e5e520ddff6846d626f8a23b35e90c5c72a6 Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Thu, 13 Jun 2019 13:51:41 +0200 Subject: [PATCH] tests/pkd: Fix OpenSSH version check When running in FIPS mode, the OpenSSH version is not the first string printed by "ssh -V". This makes the parser to find the first occurrence of the version ignoring anything printed before it. Signed-off-by: Anderson Toshiyuki Sasaki Reviewed-by: Andreas Schneider --- tests/pkd/pkd_util.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/pkd/pkd_util.c b/tests/pkd/pkd_util.c index 087d969f..0e3b19b4 100644 --- a/tests/pkd/pkd_util.c +++ b/tests/pkd/pkd_util.c @@ -43,7 +43,8 @@ static int bin_exists(const char *binary) { static int is_openssh_client_new_enough(void) { int rc = -1; FILE *fp = NULL; - char version[1024] = { 0 }; + char version_buff[1024] = { 0 }; + char *version; static int version_ok = 0; unsigned long int major = 0; @@ -59,10 +60,13 @@ static int is_openssh_client_new_enough(void) { goto done; } - if (fgets(&version[0], sizeof(version), fp) == NULL) { - fprintf(stderr, "failed to get OpenSSH client version string\n"); - goto errfgets; - } + do { + if (fgets(&version_buff[0], sizeof(version_buff), fp) == NULL) { + fprintf(stderr, "failed to get OpenSSH client version string\n"); + goto errfgets; + } + version = strstr(version_buff, "OpenSSH"); + } while(version == NULL); /* "OpenSSH_...." */ if (strlen(version) < 11) {