-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2611 from cbgbt/CVE-2022-3821
systemd: add patch for CVE-2022-3821
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters