]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
copy: do not try to copy zero size data
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 10 Dec 2024 15:47:26 +0000 (00:47 +0900)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 10 Dec 2024 19:20:50 +0000 (19:20 +0000)
Hopefully fixes the following sanitizer issue:
===
[ 3754.797377] systemd-journald[776]: ../src/src/shared/copy.c:463:37: runtime error: variable length array bound evaluates to non-positive value 0
[ 3755.101713] systemd-journald[776]: Received SIGTERM from PID 1 (systemd).
[ 3755.124580] systemd-journald[776]: Journal stopped
Found 1 sanitizer issues (0 internal, 0 asan, 0 ubsan, 0 msan).
===

src/shared/copy.c

index 836753cc750fe382f5a2fb585dfe9ecea1701a3f..5221397da5dbf0044f3eb8c68814ac29d8ceae8c 100644 (file)
@@ -346,6 +346,8 @@ int copy_bytes_full(
 
                         /* Make sure we're not copying more than the current data segment. */
                         m = MIN(m, (size_t) e - c);
+                        if (m <= 0)
+                                continue;
                 }
 
                 /* First try copy_file_range(), unless we already tried */