]> diplodocus.org Git - nmh/commit
fmt_scan(): Avoid undefined behaviour from overlapping strncpy(3).
authorRalph Corderoy <ralph@inputplus.co.uk>
Tue, 23 Jan 2018 16:37:01 +0000 (16:37 +0000)
committerRalph Corderoy <ralph@inputplus.co.uk>
Tue, 23 Jan 2018 18:05:33 +0000 (18:05 +0000)
commitff30f98e6a1ea1de5ed4ea69cc3552440ee7f26c
tree5f54bf2f38d4c5828976e27ae9de883183441516
parent20fdce3e9137be985ffb22a2c97c51bcd45f72e0
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.
sbr/fmt_scan.c