Skip to content

Commit 1a9e668

Browse files
committed
Fixed bug #42952 (soap cache file is created with insecure permissions)
1 parent a4e3969 commit 1a9e668

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

ext/soap/php_sdl.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
20152015
#ifdef ZEND_WIN32
20162016
f = open(fn,O_CREAT|O_WRONLY|O_EXCL|O_BINARY,S_IREAD|S_IWRITE);
20172017
#else
2018-
f = open(fn,O_CREAT|O_WRONLY|O_EXCL|O_BINARY,S_IREAD|S_IWRITE|S_IROTH|S_IWOTH|S_IRGRP|S_IWGRP);
2018+
f = open(fn,O_CREAT|O_WRONLY|O_EXCL|O_BINARY,S_IREAD|S_IWRITE);
20192019
#endif
20202020
if (f < 0) {return;}
20212021

@@ -3117,16 +3117,24 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
31173117
unsigned char digest[16];
31183118
int len = strlen(SOAP_GLOBAL(cache_dir));
31193119
time_t cached;
3120+
char *user = php_get_current_user();
3121+
int user_len = user ? strlen(user) + 1 : 0;
31203122

31213123
md5str[0] = '\0';
31223124
PHP_MD5Init(&context);
31233125
PHP_MD5Update(&context, (unsigned char*)uri, uri_len);
31243126
PHP_MD5Final(digest, &context);
31253127
make_digest(md5str, digest);
3126-
key = emalloc(len+sizeof("/wsdl-")-1+sizeof(md5str));
3128+
key = emalloc(len+sizeof("/wsdl-")-1+user_len+sizeof(md5str));
31273129
memcpy(key,SOAP_GLOBAL(cache_dir),len);
31283130
memcpy(key+len,"/wsdl-",sizeof("/wsdl-")-1);
3129-
memcpy(key+len+sizeof("/wsdl-")-1,md5str,sizeof(md5str));
3131+
len += sizeof("/wsdl-")-1;
3132+
if (user_len) {
3133+
memcpy(key+len, user, user_len-1);
3134+
len += user_len-1;
3135+
key[len++] = '-';
3136+
}
3137+
memcpy(key+len,md5str,sizeof(md5str));
31303138

31313139
if ((sdl = get_sdl_from_cache(key, uri, t-SOAP_GLOBAL(cache_ttl), &cached TSRMLS_CC)) != NULL) {
31323140
t = cached;

0 commit comments

Comments
 (0)