[PATCH] OpenSSH 2.1.1pl3 (portable), readconf.c and strsep(3)

Ralf S. Engelschall rse at engelschall.com
Thu Jul 13 18:26:01 EST 2000


The latest changes (replacing strtok with strsep) in OpenSSH's readconf.c
broke many ~/.ssh/config files. Actually those which uses more than one
whitespace character to separate keyword and value.

For instance my ~/.ssh/config file reads:

| BatchMode             no
| Compression           yes
| CompressionLevel      3
| FallBackToRsh         no
| UsePrivilegedPort     no
| ForwardX11            no
| KeepAlive             yes
| StrictHostKeyChecking no
| ...

And now I got errors like this:

| /u/rse/.ssh/config line 1: Missing yes/no argument.

The problem is that strsep(1) explicitly supports empty fields (= the field
between two whitespace characters) and so doesn't automatically handle config
files as above. Old config files with the "key = value" syntax are also
broken, because " = " are in OpenSSH's current parsing three whitespace
characters.

I solved the problem by skipping additional whitespace characters between the
keyword and the value with the following patch (against readconf.c from
OpenSSH 2.1.1pl3):

--- readconf.c.orig Wed Jul 12 01:45:27 2000
+++ readconf.c  Thu Jul 13 10:11:36 2000
@@ -248,6 +248,7 @@
 
    /* Get the keyword. (Each line is supposed to begin with a keyword). */
    keyword = strsep(&s, WHITESPACE);
+   s += strspn(s, WHITESPACE);
    opcode = parse_token(keyword, filename, linenum);
 
    switch (opcode) {

This made all of our ~/.ssh/config files working again.

Yours,
                                       Ralf S. Engelschall
                                       rse at engelschall.com
                                       www.engelschall.com





More information about the openssh-unix-dev mailing list