]> git.ipfire.org Git - thirdparty/rsync.git/commit
exclude: fix crashes with fortified strlcpy()
authorJiri Slaby <jslaby@suse.cz>
Fri, 18 Aug 2023 06:26:20 +0000 (08:26 +0200)
committerWayne Davison <wayne@opencoder.net>
Sat, 6 Apr 2024 15:41:41 +0000 (08:41 -0700)
commit99ab59464bf44f18d668e373bc3d0f65190b87ac
tree31d2b16030c62b406b63b4b4cb572c2e6edc999f
parenta47ae6fad901d94c1853fa27b56bc458a48bbee2
exclude: fix crashes with fortified strlcpy()

Fortified (-D_FORTIFY_SOURCE=2 for gcc) builds make strlcpy() crash when
its third parameter (size) is larger than the buffer:
  $ rsync -FFXHav '--filter=merge global-rsync-filter' Align-37-43/ xxx
  sending incremental file list
  *** buffer overflow detected ***: terminated

It's in the exclude code in setup_merge_file():
  strlcpy(y, save, MAXPATHLEN);

Note the 'y' pointer was incremented, so it no longer points to memory
with MAXPATHLEN "owned" bytes.

Fix it by remembering the number of copied bytes into the 'save' buffer
and use that instead of MAXPATHLEN which is clearly incorrect.

Fixes #511.
exclude.c