--- make-4.4.1-orig/src/expand.c 2023-01-28 18:18:16.000000000 +0300 +++ make-4.4.1/src/expand.c 2024-09-18 09:08:36.590934500 +0300 @@ -234,6 +234,17 @@ return variable_buffer; } + if (length == SIZE_MAX) + { + /* Don't copy the string if it does not contain "$". */ + p1 = strchr (string, '$'); + if (!p1) + { + o = variable_buffer_output (o, string, strlen (string) + 1); + return (variable_buffer + line_offset); + } + } + /* We need a copy of STRING: due to eval, it's possible that it will get freed as we process it (it might be the value of a variable that's reset for example). Also having a nil-terminated string is handy. */ @@ -246,7 +257,13 @@ variable output buffer, and skip them. Uninteresting chars end at the next $ or the end of the input. */ - p1 = strchr (p, '$'); + if (length == SIZE_MAX) + { + length = 0; + p1 = p + (size_t)(p1 - string); + } + else + p1 = strchr (p, '$'); o = variable_buffer_output (o, p, p1 != 0 ? (size_t) (p1 - p) : strlen (p) + 1);