From: Ralph Corderoy Date: Tue, 23 Jan 2018 16:37:01 +0000 (+0000) Subject: fmt_scan(): Avoid undefined behaviour from overlapping strncpy(3). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ff30f98e6a1ea1de5ed4ea69cc3552440ee7f26c?hp=ff30f98e6a1ea1de5ed4ea69cc3552440ee7f26c fmt_scan(): Avoid undefined behaviour from overlapping strncpy(3). M. Levinson pointed out in private email that pcc(1) tickles a bug that causes undefined behaviour due to part of `buffer[]', accessed by `str', being strncpy(3) back to its start. Fix by using memmove(3) to slide `str' back to `buffer's beginning whenever it may have wandered off. Fixes e8635a8a that added `%(unquote)', but using `%(trim)' twice was also faulty in the same way and pre-dates git. ---