mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
Avoid using %n in emacsclient
* lib-src/emacsclient.c (local_sockname): Avoid using %n (bug#50155).
This commit is contained in:
parent
e8e78809ba
commit
5b55659bae
1 changed files with 3 additions and 4 deletions
|
|
@ -1401,10 +1401,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen,
|
||||||
/* Put the full address name into the buffer, since the caller might
|
/* Put the full address name into the buffer, since the caller might
|
||||||
need it for diagnostics. But don't overrun the buffer. */
|
need it for diagnostics. But don't overrun the buffer. */
|
||||||
uintmax_t uidmax = uid;
|
uintmax_t uidmax = uid;
|
||||||
int emacsdirlen;
|
|
||||||
int suffixlen = snprintf (sockname + tmpdirlen, socknamesize - tmpdirlen,
|
int suffixlen = snprintf (sockname + tmpdirlen, socknamesize - tmpdirlen,
|
||||||
"/emacs%"PRIuMAX"%n/%s", uidmax, &emacsdirlen,
|
"/emacs%"PRIuMAX"/%s", uidmax, server_name);
|
||||||
server_name);
|
|
||||||
if (! (0 <= suffixlen && suffixlen < socknamesize - tmpdirlen))
|
if (! (0 <= suffixlen && suffixlen < socknamesize - tmpdirlen))
|
||||||
return ENAMETOOLONG;
|
return ENAMETOOLONG;
|
||||||
|
|
||||||
|
|
@ -1412,7 +1410,8 @@ local_sockname (int s, char sockname[socknamesize], int tmpdirlen,
|
||||||
this user's directory and does not let others write to it; this
|
this user's directory and does not let others write to it; this
|
||||||
fends off some symlink attacks. To avoid races, keep the parent
|
fends off some symlink attacks. To avoid races, keep the parent
|
||||||
directory open while checking. */
|
directory open while checking. */
|
||||||
char *emacsdirend = sockname + tmpdirlen + emacsdirlen;
|
char *emacsdirend = sockname + tmpdirlen + suffixlen -
|
||||||
|
strlen(server_name) - 1;
|
||||||
*emacsdirend = '\0';
|
*emacsdirend = '\0';
|
||||||
int dir = openat (AT_FDCWD, sockname,
|
int dir = openat (AT_FDCWD, sockname,
|
||||||
O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
|
O_PATH | O_DIRECTORY | O_NOFOLLOW | O_CLOEXEC);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue