From c27f012b7a447e59d4a704688971cbfa7dddaa74 Mon Sep 17 00:00:00 2001
From: Stanislav Malyshev <stas@php.net>
Date: Wed, 29 Apr 2015 22:04:20 -0700
Subject: [PATCH] Fix bug #69453 - don't try to cut empty string
---
ext/phar/tar.c | 2 +-
ext/phar/tests/bug69453.phpt | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 ext/phar/tests/bug69453.phpt
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index ca8eafc..d6d63e6 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -425,7 +425,7 @@ bail:
entry.filename_len = i;
entry.filename = pestrndup(hdr->name, i, myphar->is_persistent);
- if (entry.filename[entry.filename_len - 1] == '/') {
+ if (i > 0 && entry.filename[entry.filename_len - 1] == '/') {
/* some tar programs store directories with trailing slash */
entry.filename[entry.filename_len - 1] = '\0';
entry.filename_len--;
--
2.1.4