-/* $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
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);