Follow-up Comment #14, bug #66142 (group screen): The proposed patch works in a specific case of eval where the argument to eval is longer than 4 characters. It does not work for be with
screen -S session-name -X screen bash -c 'sleep 5' as -c yields len 2 and MAXPATHLEN-len is still larger than fits after «screen bash» The following patch seems to work more generally by tracking the remaining space in the buffer (maybe MAXPATHLEN should be replaced with «ARRAY_SIZE(m.m.command.cmd)-1» for uniformity). --- a/attacher.c 2025-02-24 20:15:31.701820351 +0100 +++ b/attacher.c 2025-02-24 20:17:05.893826559 +0100 @@ -457,13 +457,18 @@ } p = m.m.command.cmd; n = 0; + size_t buffer_size_left = MAXPATHLEN; for (; *av && n < MAXARGS - 1; ++av, ++n) { size_t len; len = strlen(*av) + 1; + if(len > buffer_size_left) { + Panic(0, "Total length of the command to send too large.\n"); + } if (p + len >= m.m.command.cmd + ARRAY_SIZE(m.m.command.cmd) - 1) break; - strncpy(p, *av, MAXPATHLEN); + strncpy(p, *av, buffer_size_left); p += len; + buffer_size_left -= len; } *p = 0; m.m.command.nargs = n; _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?66142> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
signature.asc
Description: PGP signature