Fix off-by-one

This commit is contained in:
KlzXS 2021-10-22 21:06:26 +02:00
parent 1022340aa1
commit 7857b7bc5a
No known key found for this signature in database
GPG Key ID: 6F2A29F874A14243
1 changed files with 3 additions and 3 deletions

View File

@ -5391,12 +5391,12 @@ static bool prompt_run(void)
cnt_J = 0;
next = cmdline;
while (!cnt_j && (next = strstr(next, "%J"))) {
while ((next = strstr(next, "%J"))) {
++cnt_J;
tmplen = xstrsncpy(tmpcmd, cmdline, next - cmdline + 1) - 1;
tmplen += xstrsncpy(tmpcmd + tmplen, "${0} ${@}", sizeof("${0} ${@}"));
xstrsncpy(tmpcmd + tmplen, next + 2, len - (next - cmdline + 2));
tmplen += xstrsncpy(tmpcmd + tmplen, "${0} ${@}", sizeof("${0} ${@}")) - 1;
xstrsncpy(tmpcmd + tmplen, next + 2, len - (next - cmdline + 2) + 1);
++next;
}