Skip to content

Commit

Permalink
Merge pull request #2611 from cbgbt/CVE-2022-3821
Browse files Browse the repository at this point in the history
systemd: add patch for CVE-2022-3821
  • Loading branch information
cbgbt authored Nov 23, 2022
2 parents 4a12c12 + fc1c72f commit 16e65f6
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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

0 comments on commit 16e65f6

Please sign in to comment.