blob: b1ecb552bc3233570dea7c7d48cc11a9f6669423 (
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
39
40
41
42
43
44
|
From c0a89709860acae5ef67727db7b23db385703bf6 Mon Sep 17 00:00:00 2001
From: Huzaifa Sidhpurwala <huzaifas@fedoraproject.org>
Date: Tue, 15 Oct 2013 14:39:05 +0200
Subject: [PATCH] Fix invalid memory de-reference issue
Bug: https://bugzilla.redhat.com/551415
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Upstream-Status: Backport [https://repo.or.cz/libtar.git/commit/560911b694055b0c677431cf85d4d0d5ebd1a3fd]
Signed-off-by: Katariina Lounento <katariina.lounento@vaisala.com>
---
lib/libtar.h | 1 +
lib/util.c | 4 +---
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/libtar.h b/lib/libtar.h
index 55f509a..7fc4d03 100644
--- a/lib/libtar.h
+++ b/lib/libtar.h
@@ -172,6 +172,7 @@ int th_write(TAR *t);
#define TH_ISDIR(t) ((t)->th_buf.typeflag == DIRTYPE \
|| S_ISDIR((mode_t)oct_to_int((t)->th_buf.mode)) \
|| ((t)->th_buf.typeflag == AREGTYPE \
+ && strlen((t)->th_buf.name) \
&& ((t)->th_buf.name[strlen((t)->th_buf.name) - 1] == '/')))
#define TH_ISFIFO(t) ((t)->th_buf.typeflag == FIFOTYPE \
|| S_ISFIFO((mode_t)oct_to_int((t)->th_buf.mode)))
diff --git a/lib/util.c b/lib/util.c
index 31e8315..11438ef 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -148,9 +148,7 @@ oct_to_int(char *oct)
{
int i;
- sscanf(oct, "%o", &i);
-
- return i;
+ return sscanf(oct, "%o", &i) == 1 ? i : 0;
}
|