Skip to content

Commit

Permalink
* hash.c (ruby_setenv): ENV.[]= should raise an error if setenv(3)
Browse files Browse the repository at this point in the history
  or putenv(3) fails.  [ruby-dev:40023]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
knu committed Jan 11, 2010
1 parent 73cd7b6 commit af23025
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Mon Jan 11 12:47:58 2010 Akinori MUSHA <[email protected]>

* hash.c (ruby_setenv): ENV.[]= should raise an error if setenv(3)
or putenv(3) fails. [ruby-dev:40023]

Sun Jan 10 17:25:24 2010 Nobuyoshi Nakada <[email protected]>

* lib/webrick/accesslog.rb : Escape needed.
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ with all sufficient information, see the ChangeLog file.

* ENV
* Uses locale's encoding
* ENV.[]= raises Errno::{EINVAL,ENOMEM} etc. on failure.

* Float
* new constants:
Expand Down
14 changes: 9 additions & 5 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,10 +2064,13 @@ ruby_setenv(const char *name, const char *value)
#elif defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
#undef setenv
#undef unsetenv
if (value)
setenv(name,value,1);
else
unsetenv(name);
if (value) {
if (setenv(name, value, 1))
rb_sys_fail("setenv");
} else {
if (unsetenv(name))
rb_sys_fail("unsetenv");
}
#elif defined __sun__
size_t len = strlen(name);
char **env_ptr, *str;
Expand All @@ -2081,7 +2084,8 @@ ruby_setenv(const char *name, const char *value)
if (value) {
str = malloc(len += strlen(value) + 2);
snprintf(str, len, "%s=%s", name, value);
putenv(str);
if (putenv(str))
rb_sys_fail("putenv");
}
#else /* WIN32 */
size_t len;
Expand Down

0 comments on commit af23025

Please sign in to comment.