From: Huzaifa Sidhpurwala Date: Tue, 15 Oct 2013 12:39:05 +0000 (+0200) Subject: Fix invalid memory de-reference issue X-Git-Url: https://repo.or.cz/w/libtar.git/commitdiff_plain/560911b694055b0c677431cf85d4d0d5ebd1a3fd Fix invalid memory de-reference issue Bug: https://bugzilla.redhat.com/551415 Signed-off-by: Kamil Dudka --- diff --git a/lib/libtar.h b/lib/libtar.h index 3b46a13..616ca8f 100644 --- a/lib/libtar.h +++ b/lib/libtar.h @@ -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))) 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; }