* hash.c (ruby_setenv): Improve the emulatation of setenv(3) on
environments where putenv(3) is used. Raise EINVAL If a variable name contains an '='. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8c801be9bf
commit
217a4bd283
@ -1,3 +1,9 @@
|
|||||||
|
Mon Jan 11 22:45:08 2010 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* hash.c (ruby_setenv): Improve the emulatation of setenv(3) on
|
||||||
|
environments where putenv(3) is used. Raise EINVAL If a
|
||||||
|
variable name contains an '='.
|
||||||
|
|
||||||
Mon Jan 11 18:16:38 2010 wanabe <s.wanabe@gmail.com>
|
Mon Jan 11 18:16:38 2010 wanabe <s.wanabe@gmail.com>
|
||||||
|
|
||||||
* vm_insnhelper.h (GET_BLOCK_PTR): return 0 when in class frame.
|
* vm_insnhelper.h (GET_BLOCK_PTR): return 0 when in class frame.
|
||||||
|
18
hash.c
18
hash.c
@ -2045,6 +2045,10 @@ ruby_setenv(const char *name, const char *value)
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
int len;
|
int len;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
if (strchr(name, '=')) {
|
||||||
|
errno = EINVAL;
|
||||||
|
rb_sys_fail("ruby_setenv");
|
||||||
|
}
|
||||||
if (value) {
|
if (value) {
|
||||||
len = strlen(name) + 1 + strlen(value) + 1;
|
len = strlen(name) + 1 + strlen(value) + 1;
|
||||||
buf = ALLOCA_N(char, len);
|
buf = ALLOCA_N(char, len);
|
||||||
@ -2072,8 +2076,13 @@ ruby_setenv(const char *name, const char *value)
|
|||||||
rb_sys_fail("unsetenv");
|
rb_sys_fail("unsetenv");
|
||||||
}
|
}
|
||||||
#elif defined __sun__
|
#elif defined __sun__
|
||||||
size_t len = strlen(name);
|
size_t len;
|
||||||
char **env_ptr, *str;
|
char **env_ptr, *str;
|
||||||
|
if (strchr(name, '=')) {
|
||||||
|
errno = EINVAL;
|
||||||
|
rb_sys_fail("ruby_setenv");
|
||||||
|
}
|
||||||
|
len = strlen(name);
|
||||||
for (env_ptr = GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
|
for (env_ptr = GET_ENVIRON(environ); (str = *env_ptr) != 0; ++env_ptr) {
|
||||||
if (!strncmp(str, name, len) && str[len] == '=') {
|
if (!strncmp(str, name, len) && str[len] == '=') {
|
||||||
if (!in_origenv(str)) free(str);
|
if (!in_origenv(str)) free(str);
|
||||||
@ -2089,7 +2098,12 @@ ruby_setenv(const char *name, const char *value)
|
|||||||
}
|
}
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
size_t len;
|
size_t len;
|
||||||
int i=envix(name); /* where does it go? */
|
int i;
|
||||||
|
if (strchr(name, '=')) {
|
||||||
|
errno = EINVAL;
|
||||||
|
rb_sys_fail("ruby_setenv");
|
||||||
|
}
|
||||||
|
i=envix(name); /* where does it go? */
|
||||||
|
|
||||||
if (environ == origenviron) { /* need we copy environment? */
|
if (environ == origenviron) { /* need we copy environment? */
|
||||||
int j;
|
int j;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user