Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit 0791894d84e4fbc4b07c9f9d3d3b9cbe254b0ce0 Author: Raniconduh <clagv.randomgames@gmail.com> Date: Sat Jun 18 18:42:09 2022 +0000 fix buffer overflow & replace unsafe memcpy() with memmove() diff --git a/src/main.c b/src/main.c index 8868f89..1e975d7 100644 --- a/src/main.c +++ b/src/main.c @@ -3459 +3459 @@ int main(int argc, char ** argv) {   // replace '%f' with file name cursor is on   while ((f_sep = strstr(cmdp, "%f"))) {   // escape '%f' if '%%f' is found - if (f_sep[-1] == '%') { + if (f_sep != cmd && f_sep[-1] == '%') {   size_t seplen = strlen(f_sep); - memcpy(f_sep - 1, f_sep, seplen); + memmove(f_sep - 1, f_sep, seplen);   f_sep[seplen - 1] = 0;   cmdp = f_sep + 2;   continue;