Skip to content

Commit

Permalink
upstream: make parsing user@host consistently look for the last '@' in
Browse files Browse the repository at this point in the history
the string rather than the first. This makes it possible to use usernames
that contain '@' characters.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Prompted by Max Zettlmeißl; feedback/ok millert@

OpenBSD-Commit-ID: 0b16eec246cda15469ebdcf3b1e2479810e394c5
  • Loading branch information
djmdjm committed Sep 6, 2024
1 parent 13cc78d commit a8ad7a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions match.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: match.c,v 1.44 2023/04/06 03:19:32 djm Exp $ */
/* $OpenBSD: match.c,v 1.45 2024/09/06 02:30:44 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
Expand Down Expand Up @@ -241,7 +241,7 @@ 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;
Expand All @@ -250,11 +250,11 @@ match_user(const char *user, const char *host, const char *ipaddr,
if (user == NULL)
return 0; /* shouldn't happen */

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)
Expand Down
4 changes: 2 additions & 2 deletions ssh-add.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $OpenBSD: ssh-add.c,v 1.172 2024/01/11 01:45:36 djm Exp $ */
/* $OpenBSD: ssh-add.c,v 1.173 2024/09/06 02:30:44 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
Expand Down Expand Up @@ -698,7 +698,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';
Expand Down

0 comments on commit a8ad7a2

Please sign in to comment.