[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix config file reading


Hello,

I've found that libssh 0.7.5 fails to read a configuration file with
'ssh_options_parse_config' procedure due to a wrong check in
'ssh_config_parse_line' procedure: all *unseen* opcodes are effectively
skipped.  The problem is present on the 'master' branch as well.  To my
understanding, the problem was introduced in
'5f202d7ffa48f2ee989e0e6c1e761963c68ab08f' commit.

I prepared a patch that fixes the aforementioned check.  I did some
tests with my libssh based project and it seems that the patch works OK
for me.  Please find the patch attached.

Thanks!

- Artyom

-- 
Artyom V. Poptsov <poptsov.artyom@xxxxxxxxx>;  GPG Key: 0898A02F
Home page: http://poptsov-artyom.narod.ru/
From 6a8bd601852765c0b1f6cab72bff25056cfbd8b4 Mon Sep 17 00:00:00 2001
From: "Artyom V. Poptsov" <poptsov.artyom@xxxxxxxxx>
Date: Sun, 4 Jun 2017 11:54:55 +0300
Subject: [PATCH] config: Bugfix: Don't skip unseen opcodes

libssh fails to read the configuration from a config file due to a
wrong check in 'ssh_config_parse_line' procedure in 'config.c'; it's
effectively skipping every opcode (and therefore every option) from
the file.  The change fixes that behaviour.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@xxxxxxxxx>
---
 src/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/config.c b/src/config.c
index 6478fc5f..ae7e48d7 100644
--- a/src/config.c
+++ b/src/config.c
@@ -219,7 +219,7 @@ static int ssh_config_parse_line(ssh_session session, const char *line,
 
   opcode = ssh_config_get_opcode(keyword);
   if (*parsing == 1 && opcode != SOC_HOST) {
-      if (seen[opcode] == 0) {
+      if (seen[opcode]) {
           return 0;
       }
       seen[opcode] = 1;
-- 
2.13.0

Attachment: signature.asc
Description: PGP signature


Follow-Ups:
Re: [PATCH] Fix config file readingAndreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org