libarchive: CVE-2022-36227 NULL pointer dereference in archive_write.c

Upstream-Status: Backport from bff38efe8c

(From OE-Core rev: c39fd8264ac623f3cfb26305420b527dd9c4c891)

Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Hitendra Prajapati
2022-12-08 12:56:27 +05:30
committed by Richard Purdie
parent b4fc8a65f5
commit 3ff484966d
2 changed files with 44 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
From 6311080bff566fcc5591dadfd78efb41705b717f Mon Sep 17 00:00:00 2001
From: obiwac <obiwac@gmail.com>
Date: Fri, 22 Jul 2022 22:41:10 +0200
Subject: [PATCH] CVE-2022-36227
libarchive: CVE-2022-36227 Handle a `calloc` returning NULL (fixes #1754)
Upstream-Status: Backport [https://github.com/libarchive/libarchive/commit/bff38efe8c110469c5080d387bec62a6ca15b1a5]
CVE: CVE-2022-36227
Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com
---
libarchive/archive_write.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/libarchive/archive_write.c b/libarchive/archive_write.c
index 98a55fb..7fe88b6 100644
--- a/libarchive/archive_write.c
+++ b/libarchive/archive_write.c
@@ -211,6 +211,10 @@ __archive_write_allocate_filter(struct archive *_a)
struct archive_write_filter *f;
f = calloc(1, sizeof(*f));
+
+ if (f == NULL)
+ return (NULL);
+
f->archive = _a;
f->state = ARCHIVE_WRITE_FILTER_STATE_NEW;
if (a->filter_first == NULL)
@@ -527,6 +531,10 @@ archive_write_open(struct archive *_a, void *client_data,
a->client_data = client_data;
client_filter = __archive_write_allocate_filter(_a);
+
+ if (client_filter == NULL)
+ return (ARCHIVE_FATAL);
+
client_filter->open = archive_write_client_open;
client_filter->write = archive_write_client_write;
client_filter->close = archive_write_client_close;
--
2.25.1

View File

@@ -39,6 +39,7 @@ SRC_URI = "http://libarchive.org/downloads/libarchive-${PV}.tar.gz \
file://CVE-2021-23177.patch \
file://CVE-2021-31566-01.patch \
file://CVE-2021-31566-02.patch \
file://CVE-2022-36227.patch \
"
SRC_URI[md5sum] = "d953ed6b47694dadf0e6042f8f9ff451"