[openssh-commits] [openssh] 01/03: upstream: Use strprefix helper when processing sshd -C test args
git+noreply at mindrot.org
git+noreply at mindrot.org
Thu Feb 6 09:41:25 AEDT 2025
This is an automated email from the git hooks/post-receive script.
djm pushed a commit to branch master
in repository openssh.
commit 0643994b20f2cc54bca80842a984b3052ff1a6a9
Author: dtucker at openbsd.org <dtucker at openbsd.org>
AuthorDate: Wed Jan 15 22:23:13 2025 +0000
upstream: Use strprefix helper when processing sshd -C test args
instead of counting bytes by hand. ok djm@
OpenBSD-Commit-ID: 2866d369d96fe04bf76112260ac37e489f98a9a9
---
servconf.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/servconf.c b/servconf.c
index 2abf2846..112b6579 100644
--- a/servconf.c
+++ b/servconf.c
@@ -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 at 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);
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list