Fix invalid memory de-reference issue
authorHuzaifa Sidhpurwala <huzaifas@fedoraproject.org>
Tue, 15 Oct 2013 12:39:05 +0000 (15 14:39 +0200)
committerChris Frey <cdfrey@foursquare.net>
Tue, 15 Oct 2013 23:14:24 +0000 (15 19:14 -0400)
Bug: https://bugzilla.redhat.com/551415

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
lib/libtar.h
lib/util.c

index 3b46a13..616ca8f 100644 (file)
@@ -173,6 +173,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)))
index 31e8315..11438ef 100644 (file)
@@ -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;
 }