[PATCH] dsync: fix splitting login from host
Using strchr() was splitting login and host at the first occurrence of '@' which leads to troublesome behaviour. When calling strace one would notice the misbehaviour: execve("/usr/sbin/ssh", ["ssh", "-lthomas", "domain.org@10.8.13.2" using strrch() however splits login and host at the last occurrence of '@'. Signed-off-by: Thomas Reifferscheid <thomas@reifferscheid.org> --- src/doveadm/doveadm-dsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doveadm/doveadm-dsync.c b/src/doveadm/doveadm-dsync.c index caf569f1d..3b8d4549a 100644 --- a/src/doveadm/doveadm-dsync.c +++ b/src/doveadm/doveadm-dsync.c @@ -479,7 +479,7 @@ parse_ssh_location(const char *location, const char *username) { const char *host, *login; - host = strchr(location, '@'); + host = strrchr(location, '@'); if (host != NULL) login = t_strdup_until(location, host++); else { -- 2.11.0
On 03.07.2017 23:06, Thomas Reifferscheid wrote:
Using strchr() was splitting login and host at the first occurrence of '@' which leads to troublesome behaviour. When calling strace one would notice the misbehaviour:
execve("/usr/sbin/ssh", ["ssh", "-lthomas", "domain.org@10.8.13.2"
using strrch() however splits login and host at the last occurrence of '@'.
Signed-off-by: Thomas Reifferscheid <thomas@reifferscheid.org> --- src/doveadm/doveadm-dsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/doveadm/doveadm-dsync.c b/src/doveadm/doveadm-dsync.c index caf569f1d..3b8d4549a 100644 --- a/src/doveadm/doveadm-dsync.c +++ b/src/doveadm/doveadm-dsync.c @@ -479,7 +479,7 @@ parse_ssh_location(const char *location, const char *username) { const char *host, *login;
- host = strchr(location, '@'); + host = strrchr(location, '@'); if (host != NULL) login = t_strdup_until(location, host++); else {
Hi! Thanks! Merged. Aki
participants (2)
-
Aki Tuomi
-
Thomas Reifferscheid