Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

svn: /php/php-src/ branches/PHP_5_3/main/php_ini.c trunk/main/php_ini.c

96 views
Skip to first unread message

Pierre Joye

unread,
Aug 30, 2010, 1:05:56 PM8/30/10
to php...@lists.php.net
pajoye Mon, 30 Aug 2010 17:05:56 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=302899

Log:
- fix possible leak and error while fetching PHPRC

Changed paths:
U php/php-src/branches/PHP_5_3/main/php_ini.c
U php/php-src/trunk/main/php_ini.c

Modified: php/php-src/branches/PHP_5_3/main/php_ini.c
===================================================================
--- php/php-src/branches/PHP_5_3/main/php_ini.c 2010-08-30 17:01:36 UTC (rev 302898)
+++ php/php-src/branches/PHP_5_3/main/php_ini.c 2010-08-30 17:05:56 UTC (rev 302899)
@@ -398,13 +398,35 @@
static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
#ifdef PHP_WIN32
char *reg_location;
+ char phprc_path[MAXPATHLEN];
#endif

env_location = getenv("PHPRC");
+
+#ifdef PHP_WIN32
if (!env_location) {
- env_location = "";
+ char dummybuf;
+ int size;
+
+ SetLastError(0);
+
+ /*If the given bugger is not large enough to hold the data, the return value is
+ the buffer size, in characters, required to hold the string and its terminating
+ null character. We use this return value to alloc the final buffer. */
+ size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
+ if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+ /* The environment variable doesn't exist. */
+ env_location = "";
+ } else {
+ if (size == 0) {
+ env_location = "";
+ } else {
+ size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
+ env_location = phprc_path;
+ }
+ }
}
-
+#endif
/*
* Prepare search path
*/

Modified: php/php-src/trunk/main/php_ini.c
===================================================================
--- php/php-src/trunk/main/php_ini.c 2010-08-30 17:01:36 UTC (rev 302898)
+++ php/php-src/trunk/main/php_ini.c 2010-08-30 17:05:56 UTC (rev 302899)
@@ -396,13 +396,35 @@
static const char paths_separator[] = { ZEND_PATHS_SEPARATOR, 0 };
#ifdef PHP_WIN32
char *reg_location;
+ char phprc_path[MAXPATHLEN];
#endif

env_location = getenv("PHPRC");
+
+#ifdef PHP_WIN32
if (!env_location) {
- env_location = "";
+ char dummybuf;
+ int size;
+
+ SetLastError(0);
+
+ /*If the given bugger is not large enough to hold the data, the return value is
+ the buffer size, in characters, required to hold the string and its terminating
+ null character. We use this return value to alloc the final buffer. */
+ size = GetEnvironmentVariableA("PHPRC", &dummybuf, 0);
+ if (GetLastError() == ERROR_ENVVAR_NOT_FOUND) {
+ /* The environment variable doesn't exist. */
+ env_location = "";
+ } else {
+ if (size == 0) {
+ env_location = "";
+ } else {
+ size = GetEnvironmentVariableA("PHPRC", phprc_path, size);
+ env_location = phprc_path;
+ }
+ }
}
-
+#endif
/*
* Prepare search path
*/

Felipe Pena

unread,
Aug 30, 2010, 5:34:54 PM8/30/10
to php...@lists.php.net
felipe Mon, 30 Aug 2010 21:34:54 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=302903

Log:
- Fixed crash on non-Windows build

Changed paths:
U php/php-src/branches/PHP_5_3/main/php_ini.c
U php/php-src/trunk/main/php_ini.c

Modified: php/php-src/branches/PHP_5_3/main/php_ini.c
===================================================================
--- php/php-src/branches/PHP_5_3/main/php_ini.c 2010-08-30 18:13:28 UTC (rev 302902)
+++ php/php-src/branches/PHP_5_3/main/php_ini.c 2010-08-30 21:34:54 UTC (rev 302903)
@@ -426,6 +426,10 @@
}
}
}
+#else
+ if (!env_location) {
+ env_location = "";
+ }


#endif
/*
* Prepare search path

Modified: php/php-src/trunk/main/php_ini.c
===================================================================
--- php/php-src/trunk/main/php_ini.c 2010-08-30 18:13:28 UTC (rev 302902)
+++ php/php-src/trunk/main/php_ini.c 2010-08-30 21:34:54 UTC (rev 302903)
@@ -424,6 +424,10 @@
}
}
}
+#else
+ if (!env_location) {
+ env_location = "";
+ }

0 new messages