Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: add patch for CVE-2022-3821 #2611

Merged
merged 1 commit into from
Nov 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions packages/systemd/0002-time-util-fix-buffer-over-run.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 9102c625a673a3246d7e73d8737f3494446bad4e Mon Sep 17 00:00:00 2001
From: Yu Watanabe <[email protected]>
Date: Thu, 7 Jul 2022 18:27:02 +0900
Subject: [PATCH] time-util: fix buffer-over-run

Fixes #23928.
---
src/basic/time-util.c | 2 +-
src/test/test-time-util.c | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index abbc4ad5cd..26d59de123 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -591,7 +591,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
t = b;
}

- n = MIN((size_t) k, l);
+ n = MIN((size_t) k, l-1);

l -= n;
p += n;
diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c
index e8e4e2a67b..58c5fa9be4 100644
--- a/src/test/test-time-util.c
+++ b/src/test/test-time-util.c
@@ -238,6 +238,11 @@ TEST(format_timespan) {
test_format_timespan_accuracy(1);
test_format_timespan_accuracy(USEC_PER_MSEC);
test_format_timespan_accuracy(USEC_PER_SEC);
+
+ /* See issue #23928. */
+ _cleanup_free_ char *buf;
+ assert_se(buf = new(char, 5));
+ assert_se(buf == format_timespan(buf, 5, 100005, 1000));
}

TEST(verify_timezone) {
--
2.37.1

3 changes: 3 additions & 0 deletions packages/systemd/systemd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Source4: issue
# Add fix for glibc 2.36+
Patch0001: 0001-glibc-Remove-include-linux-fs.h-to-resolve-fsconfig_.patch

# Upstream patch for CVE-2022-3821
Patch0002: 0002-time-util-fix-buffer-over-run.patch

# Local patch to work around the fact that /var is a bind mount from
# /local/var, and we want the /local/var/run symlink to point to /run.
Patch9001: 9001-use-absolute-path-for-var-run-symlink.patch
Expand Down