From: Todd Lewis Date: Thu, 15 Jul 2021 05:34:00 +0000 (-0400) Subject: rename: stop after count changes X-Git-Tag: v2.38-rc1~340^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0e402c354bffed699e66b9eed870c9381a48288;p=thirdparty%2Futil-linux.git rename: stop after count changes --- diff --git a/misc-utils/rename.c b/misc-utils/rename.c index 3b0aed0227..4e9f40ba06 100644 --- a/misc-utils/rename.c +++ b/misc-utils/rename.c @@ -68,7 +68,7 @@ static int string_replace(char *from, char *to, char *s, char *orig, char **newn p = orig; *newname = xmalloc(strlen(orig) - count * fromlen + count * strlen(to) + 1); q = *newname; - while (where) { + while (count--) { while (p < where) *q++ = *p++; p = to;