Skip to content

Commit 3e5675d

Browse files
committed
Remove unnecessary strncpy in zip
This causes a warning on GCC 9 and is unnecessary to boot: We only use "cwd" for the open_basedir check, so we can just as well pass in the original string.
1 parent 6f63e05 commit 3e5675d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

ext/zip/php_zip.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,9 @@ static char * php_zipobj_get_zip_comment(struct zip *za, int *len) /* {{{ */
509509
int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_value) /* {{{ */
510510
{
511511
#ifdef HAVE_GLOB
512-
char cwd[MAXPATHLEN];
513512
int cwd_skip = 0;
514513
#ifdef ZTS
514+
char cwd[MAXPATHLEN];
515515
char work_pattern[MAXPATHLEN];
516516
char *result;
517517
#endif
@@ -574,8 +574,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v
574574

575575
/* we assume that any glob pattern will match files from one directory only
576576
so checking the dirname of the first match should be sufficient */
577-
strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN);
578-
if (ZIP_OPENBASEDIR_CHECKPATH(cwd)) {
577+
if (ZIP_OPENBASEDIR_CHECKPATH(globbuf.gl_pathv[0])) {
579578
return -1;
580579
}
581580

0 commit comments

Comments
 (0)