]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Use strprefix helper when processing sshd -C test args
authordtucker@openbsd.org <dtucker@openbsd.org>
Wed, 15 Jan 2025 22:23:13 +0000 (22:23 +0000)
committerDamien Miller <djm@mindrot.org>
Wed, 5 Feb 2025 22:40:16 +0000 (09:40 +1100)
instead of counting bytes by hand.  ok djm@

OpenBSD-Commit-ID: 2866d369d96fe04bf76112260ac37e489f98a9a9

servconf.c

index 2abf2846a2c7132be0d3155c3367964e313f1f3b..112b657999612c8a34085915a0ddb4a8abca41f6 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: servconf.c,v 1.419 2024/09/25 01:24:04 djm Exp $ */
+/* $OpenBSD: servconf.c,v 1.421 2025/01/15 22:23:13 dtucker Exp $ */
 /*
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
  *                    All rights reserved
@@ -2808,23 +2808,25 @@ parse_server_match_config(ServerOptions *options,
        copy_set_server_options(options, &mo, 0);
 }
 
-int parse_server_match_testspec(struct connection_info *ci, char *spec)
+int
+parse_server_match_testspec(struct connection_info *ci, char *spec)
 {
        char *p;
+       const char *val;
 
        while ((p = strsep(&spec, ",")) && *p != '\0') {
-               if (strncmp(p, "addr=", 5) == 0) {
-                       ci->address = xstrdup(p + 5);
-               } else if (strncmp(p, "host=", 5) == 0) {
-                       ci->host = xstrdup(p + 5);
-               } else if (strncmp(p, "user=", 5) == 0) {
-                       ci->user = xstrdup(p + 5);
-               } else if (strncmp(p, "laddr=", 6) == 0) {
-                       ci->laddress = xstrdup(p + 6);
-               } else if (strncmp(p, "rdomain=", 8) == 0) {
-                       ci->rdomain = xstrdup(p + 8);
-               } else if (strncmp(p, "lport=", 6) == 0) {
-                       ci->lport = a2port(p + 6);
+               if ((val = strprefix(p, "addr=", 0)) != NULL) {
+                       ci->address = xstrdup(val);
+               } else if ((val = strprefix(p, "host=", 0)) != NULL) {
+                       ci->host = xstrdup(val);
+               } else if ((val = strprefix(p, "user=", 0)) != NULL) {
+                       ci->user = xstrdup(val);
+               } else if ((val = strprefix(p, "laddr=", 0)) != NULL) {
+                       ci->laddress = xstrdup(val);
+               } else if ((val = strprefix(p, "rdomain=", 0)) != NULL) {
+                       ci->rdomain = xstrdup(val);
+               } else if ((val = strprefix(p, "lport=", 0)) != NULL) {
+                       ci->lport = a2port(val);
                        if (ci->lport == -1) {
                                fprintf(stderr, "Invalid port '%s' in test mode"
                                    " specification %s\n", p+6, p);