From: Lars Ingebrigtsen Date: Mon, 25 Apr 2022 08:46:28 +0000 (+0200) Subject: Protect against the host name containing an alpha character X-Git-Tag: emacs-29.0.90~1931^2~315 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=9fdaf9ac4d0d26f93ffa4376ec26be9e33816f6a;p=emacs.git Protect against the host name containing an alpha character * src/filelock.c (lock_file_1, current_lock_owner): Protect against the unlikely case that the host name contains an alpha character (bug#14250). --- diff --git a/src/filelock.c b/src/filelock.c index 67948e1f099..a657cc4582c 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -419,6 +419,13 @@ lock_file_1 (Lisp_Object lfname, bool force) Lisp_Object luser_name = Fuser_login_name (Qnil); Lisp_Object lhost_name = Fsystem_name (); + /* Protect against the extremely unlikely case of the host name + containing an @ character. */ + if (!NILP (lhost_name) && strchr (SSDATA (lhost_name), '@')) + lhost_name = CALLN (Ffuncall, intern ("string-replace"), + build_string ("@"), build_string ("-"), + lhost_name); + char const *user_name = STRINGP (luser_name) ? SSDATA (luser_name) : ""; char const *host_name = STRINGP (lhost_name) ? SSDATA (lhost_name) : ""; char lock_info_str[MAX_LFINFO + 1]; @@ -583,6 +590,12 @@ current_lock_owner (lock_info_type *owner, Lisp_Object lfname) .#test.txt -> larsi@.118961:1646577954) is an empty string. */ if (NILP (system_name)) system_name = build_string (""); + /* Protect against the extremely unlikely case of the host name + containing an @ character. */ + else if (strchr (SSDATA (system_name), '@')) + system_name = CALLN (Ffuncall, intern ("string-replace"), + build_string ("@"), build_string ("-"), + system_name); /* On current host? */ if (STRINGP (system_name) && dot - (at + 1) == SBYTES (system_name)