summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-08-01 05:03:54 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-08-01 15:45:53 +0200
commitf7012a93a7f04fa29c7933a4963aa17fcf120e97 (patch)
tree66265fb621ba4db0db04829a2cd007e8bed345b7 /src/import
parenttest: use ASSERT_OK_ERRNO() for setenv() and unsetenv() (diff)
downloadsystemd-f7012a93a7f04fa29c7933a4963aa17fcf120e97.tar.xz
systemd-f7012a93a7f04fa29c7933a4963aa17fcf120e97.zip
import: check overflow
Fixes CID#1548022 and CID#1548075.
Diffstat (limited to 'src/import')
-rw-r--r--src/import/import-raw.c5
-rw-r--r--src/import/import-tar.c5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index ee9b297bfe..78775b96d6 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -409,6 +409,11 @@ static int raw_import_process(RawImport *i) {
goto finish;
}
+ if ((size_t) l > sizeof(i->buffer) - i->buffer_size) {
+ r = log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Read input file exceeded maximum size.");
+ goto finish;
+ }
+
i->buffer_size += l;
if (i->compress.type == IMPORT_COMPRESS_UNKNOWN) {
diff --git a/src/import/import-tar.c b/src/import/import-tar.c
index 39df11b5ff..976c918246 100644
--- a/src/import/import-tar.c
+++ b/src/import/import-tar.c
@@ -276,6 +276,11 @@ static int tar_import_process(TarImport *i) {
goto finish;
}
+ if ((size_t) l > sizeof(i->buffer) - i->buffer_size) {
+ r = log_error_errno(SYNTHETIC_ERRNO(EBADMSG), "Read input file exceeded maximum size.");
+ goto finish;
+ }
+
i->buffer_size += l;
if (i->compress.type == IMPORT_COMPRESS_UNKNOWN) {