Skip to content

Commit

Permalink
import: check overflow
Browse files Browse the repository at this point in the history
Fixes CID#1548022 and CID#1548075.

(cherry picked from commit f7012a93a7f04fa29c7933a4963aa17fcf120e97)
(cherry picked from commit 11c15905cd4759b89a1da63d05772c1f7c3744a4)
(cherry picked from commit a920cc9)
  • Loading branch information
yuwata authored and bluca committed Aug 19, 2024
1 parent 73767db commit ff17a10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/import/import-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,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) {
Expand Down
5 changes: 5 additions & 0 deletions src/import/import-tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,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) {
Expand Down

0 comments on commit ff17a10

Please sign in to comment.