summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/zip/zip-3.0/0001-fileio.c-fix-a-buffer-overflow-detected-issue.patch
blob: d760dfcec5a00f8cd685d976e36f4e7f7c010247 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From 23b4ed82bff20c737fe2e95d5b035e92a9522ca2 Mon Sep 17 00:00:00 2001
From: Ming Liu <liu.ming50@gmail.com>
Date: Thu, 15 May 2025 13:58:45 +0200
Subject: [PATCH] fileio.c: fix a buffer overflow detected issue
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix a following issue:
| *** buffer overflow detected ***: terminated
|
| zip error: Interrupted (aborting)

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=2165653

Upstream-Status: Inactive-Upstream [the fix is from Redhat but not the official project]

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
 fileio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fileio.c b/fileio.c
index 1847e62..5a2959d 100644
--- a/fileio.c
+++ b/fileio.c
@@ -3502,7 +3502,7 @@ zwchar *local_to_wide_string(local_string)
   if ((wc_string = (wchar_t *)malloc((wsize + 1) * sizeof(wchar_t))) == NULL) {
     ZIPERR(ZE_MEM, "local_to_wide_string");
   }
-  wsize = mbstowcs(wc_string, local_string, strlen(local_string) + 1);
+  wsize = mbstowcs(wc_string, local_string, wsize + 1);
   wc_string[wsize] = (wchar_t) 0;
 
   /* in case wchar_t is not zwchar */
-- 
2.43.0