Skip to content

Commit 9d53371

Browse files
committed
ext/phar: reduce scope of variables and clean up CS
1 parent 239a8be commit 9d53371

3 files changed

Lines changed: 10 additions & 14 deletions

File tree

ext/phar/func_interceptors.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -337,15 +337,12 @@ static void phar_fancy_stat(zend_stat_t *stat_sb, int type, zval *return_value)
337337
wmask=S_IWGRP;
338338
xmask=S_IXGRP;
339339
} else {
340-
int groups, n, i;
341-
gid_t *gids;
342-
343-
groups = getgroups(0, NULL);
344-
if(groups > 0) {
345-
gids=(gid_t *)safe_emalloc(groups, sizeof(gid_t), 0);
346-
n=getgroups(groups, gids);
347-
for(i=0;i<n;++i){
348-
if(stat_sb->st_gid==gids[i]) {
340+
int groups = getgroups(0, NULL);
341+
if (groups > 0) {
342+
gid_t *gids = safe_emalloc(groups, sizeof(gid_t), 0);
343+
int n = getgroups(groups, gids);
344+
for(int i = 0; i < n; ++i){
345+
if (stat_sb->st_gid==gids[i]) {
349346
rmask=S_IRGRP;
350347
wmask=S_IWGRP;
351348
xmask=S_IXGRP;

ext/phar/phar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ HashTable cached_alias;
9191
static void phar_split_cache_list(void) /* {{{ */
9292
{
9393
char *tmp;
94-
char *key, *lasts, *end;
94+
char *key, *lasts;
9595
char ds[2];
9696
phar_archive_data *phar;
9797
uint32_t i = 0;
@@ -124,7 +124,7 @@ static void phar_split_cache_list(void) /* {{{ */
124124
key;
125125
key = php_strtok_r(NULL, ds, &lasts)) {
126126
size_t len;
127-
end = strchr(key, DEFAULT_DIR_SEPARATOR);
127+
const char *end = strchr(key, DEFAULT_DIR_SEPARATOR);
128128
if (end) {
129129
len = end - key;
130130
} else {

ext/phar/phar_object.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,9 @@ static void phar_do_403(void) /* {{{ */
319319
static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len, zend_string *f404) /* {{{ */
320320
{
321321
sapi_header_line ctr = {0};
322-
phar_entry_info *info;
323322

324323
if (phar && f404 && ZSTR_LEN(f404)) {
325-
info = phar_get_entry_info(phar, ZSTR_VAL(f404), ZSTR_LEN(f404), NULL, true);
324+
phar_entry_info *info = phar_get_entry_info(phar, ZSTR_VAL(f404), ZSTR_LEN(f404), NULL, true);
326325

327326
if (info) {
328327
/* Status doesn't matter, we're exiting anyway. */
@@ -344,7 +343,7 @@ static void phar_do_404(phar_archive_data *phar, char *fname, size_t fname_len,
344343
/* post-process REQUEST_URI and retrieve the actual request URI. This is for
345344
cases like http://localhost/blah.phar/path/to/file.php/extra/stuff
346345
which calls "blah.phar" file "path/to/file.php" with PATH_INFO "/extra/stuff" */
347-
static void phar_postprocess_ru_web(char *fname, size_t fname_len, char *entry, size_t *entry_len, char **ru, size_t *ru_len) /* {{{ */
346+
static void phar_postprocess_ru_web(const char *fname, size_t fname_len, char *entry, size_t *entry_len, char **ru, size_t *ru_len) /* {{{ */
348347
{
349348
char *e = entry + 1, *u1 = NULL, *u = NULL, *saveu = NULL;
350349
size_t e_len = *entry_len - 1, u_len = 0;

0 commit comments

Comments
 (0)