Remove unnecessary strncpy in zip
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 3 Jan 2020 10:51:46 +0000 (11:51 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 3 Jan 2020 10:53:03 +0000 (11:53 +0100)
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.

ext/zip/php_zip.c

index 966efb58e6980aee1704ea429104562d0c01fdb3..9520ecb9caa9792b64a938998797e353f852609a 100644 (file)
@@ -509,9 +509,9 @@ static char * php_zipobj_get_zip_comment(struct zip *za, int *len) /* {{{ */
 int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_value) /* {{{ */
 {
 #ifdef HAVE_GLOB
-       char cwd[MAXPATHLEN];
        int cwd_skip = 0;
 #ifdef ZTS
+       char cwd[MAXPATHLEN];
        char work_pattern[MAXPATHLEN];
        char *result;
 #endif
@@ -574,8 +574,7 @@ int php_zip_glob(char *pattern, int pattern_len, zend_long flags, zval *return_v
 
        /* we assume that any glob pattern will match files from one directory only
           so checking the dirname of the first match should be sufficient */
-       strncpy(cwd, globbuf.gl_pathv[0], MAXPATHLEN);
-       if (ZIP_OPENBASEDIR_CHECKPATH(cwd)) {
+       if (ZIP_OPENBASEDIR_CHECKPATH(globbuf.gl_pathv[0])) {
                return -1;
        }