summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-19 08:31:04 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-19 08:31:04 +0000
commit20316027872b9a3a70babc884f838f499f1e5746 (patch)
treeffade6e5d1945bcecdd7236487b5f94a59b501a6 /hash.c
parent1fb55b9d7704c4e3df0118fe33890b65538dd06a (diff)
* signal.c (trap): remove sigexit(); handle "EXIT" via sig_exec().
[ruby-dev:26440] * io.c (rb_io_inspect): replace sprintf() with "%s" format all over the place by snprintf() to avoid integer overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 05491f0d9d..f221418b60 100644
--- a/hash.c
+++ b/hash.c
@@ -1809,7 +1809,7 @@ ruby_setenv(name, value)
else
unsetenv(name);
#else /* WIN32 */
-
+ size_t len;
int i=envix(name); /* where does it go? */
if (environ == origenviron) { /* need we copy environment? */
@@ -1842,9 +1842,10 @@ ruby_setenv(name, value)
REALLOC_N(environ, char*, i+2); /* just expand it a bit */
environ[i+1] = 0; /* make sure it's null terminated */
}
- environ[i] = ALLOC_N(char, strlen(name) + strlen(value) + 2);
+ len = strlen(name) + strlen(value) + 2;
+ environ[i] = ALLOC_N(char, len);
#ifndef MSDOS
- sprintf(environ[i],"%s=%s",name,value); /* all that work just for this */
+ snprintf(environ[i],len,"%s=%s",name,value); /* all that work just for this */
#else
/* MS-DOS requires environment variable names to be in uppercase */
/* [Tom Dinger, 27 August 1990: Well, it doesn't _require_ it, but