From a8ad7a2952111c6ce32949a775df94286550af6b Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Fri, 6 Sep 2024 02:30:44 +0000 Subject: [PATCH] upstream: make parsing user@host consistently look for the last '@' in the string rather than the first. This makes it possible to use usernames that contain '@' characters. Conflict:NA Reference:https://anongit.mindrot.org/openssh.git/commit/a8ad7a2952111c6ce32949a775df94286550af6b --- match.c | 6 +++--- ssh-add.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/match.c b/match.c index 3ac854d..b9a8225 100644 --- a/match.c +++ b/match.c @@ -241,17 +241,17 @@ match_user(const char *user, const char *host, const char *ipaddr, /* test mode */ if (user == NULL && host == NULL && ipaddr == NULL) { - if ((p = strchr(pattern, '@')) != NULL && + if ((p = strrchr(pattern, '@')) != NULL && match_host_and_ip(NULL, NULL, p + 1) < 0) return -1; return 0; } - if ((p = strchr(pattern, '@')) == NULL) + if (strrchr(pattern, '@') == NULL) return match_pattern(user, pattern); pat = xstrdup(pattern); - p = strchr(pat, '@'); + p = strrchr(pat, '@'); *p++ = '\0'; if ((ret = match_pattern(user, pat)) == 1) diff --git a/ssh-add.c b/ssh-add.c index 8cba0a7..2b081d6 100644 --- a/ssh-add.c +++ b/ssh-add.c @@ -712,7 +712,7 @@ parse_dest_constraint_hop(const char *s, struct dest_constraint_hop *dch, memset(dch, '\0', sizeof(*dch)); os = xstrdup(s); - if ((host = strchr(os, '@')) == NULL) + if ((host = strrchr(os, '@')) == NULL) host = os; else { *host++ = '\0'; -- 2.43.0