diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | hash.c | 6 |
2 files changed, 8 insertions, 2 deletions
@@ -1,3 +1,7 @@ +Fri Nov 28 19:28:18 2003 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * hash.c (env_has_value, env_index): must match exactly. + Fri Nov 28 17:59:20 2003 NAKAMURA Usaku <usa@ruby-lang.org> * test/ruby/test_env.rb: add tests for ENV. @@ -1598,7 +1598,8 @@ env_has_value(dmy, value) while (*env) { char *s = strchr(*env, '='); if (s++) { - if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) { + long len = strlen(s); + if (RSTRING(value)->len == len && strncmp(s, RSTRING(value)->ptr, len) == 0) { FREE_ENVIRON(environ); return Qtrue; } @@ -1621,7 +1622,8 @@ env_index(dmy, value) while (*env) { char *s = strchr(*env, '='); if (s++) { - if (strncmp(s, RSTRING(value)->ptr, strlen(s)) == 0) { + long len = strlen(s); + if (RSTRING(value)->len == len && strncmp(s, RSTRING(value)->ptr, len) == 0) { str = env_str_new(*env, s-*env-1); FREE_ENVIRON(environ); return str; |