blob: 11bddd768877c4def4811d9265974224e67009b6 (
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
|
From 86690e6824c175e1fa7710ead34beb1d73c5a850 Mon Sep 17 00:00:00 2001
From: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Date: Wed, 10 Nov 2021 01:21:46 +0300
Subject: [PATCH 3/4] Do not let dirname tamper with inputFile
The function dirname() can change passed string, resulting in
pFiles.inputFile being changed. To prevent pFiles.inputFile change, pass
a copy of the string to the dirname().
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
src/qc_image_unpacker.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qc_image_unpacker.c b/src/qc_image_unpacker.c
index ea7fd0779645..faddf6b1dd21 100644
--- a/src/qc_image_unpacker.c
+++ b/src/qc_image_unpacker.c
@@ -114,7 +114,7 @@ int main(int argc, char **argv) {
// It output directory not set, put extracted images under input directory
if (!pRunArgs.outputDir)
pRunArgs.outputDir =
- utils_isValidDir(pFiles.inputFile) ? pFiles.inputFile : dirname(pFiles.inputFile);
+ utils_isValidDir(pFiles.inputFile) ? pFiles.inputFile : dirname(strdup(pFiles.inputFile));
size_t processedImgs = 0;
LOGMSG(l_INFO, "Processing %zu file(s) from %s", pFiles.fileCnt, pFiles.inputFile);
--
2.35.1
|