summaryrefslogtreecommitdiffstats
path: root/generic/tclEnv.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclEnv.c')
-rw-r--r--generic/tclEnv.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/generic/tclEnv.c b/generic/tclEnv.c
index a516cce..bd710d6 100644
--- a/generic/tclEnv.c
+++ b/generic/tclEnv.c
@@ -161,7 +161,8 @@ TclSetEnv(
const char *value) /* New value for variable (UTF-8). */
{
Tcl_DString envString;
- int index, length, nameLength;
+ unsigned nameLength, valueLength;
+ int index, length;
char *p, *oldValue;
const char *p2;
@@ -218,7 +219,7 @@ TclSetEnv(
Tcl_DStringFree(&envString);
oldValue = environ[index];
- nameLength = length;
+ nameLength = (unsigned) length;
}
/*
@@ -227,18 +228,19 @@ TclSetEnv(
* and set the environ array value.
*/
- p = ckalloc((unsigned) nameLength + strlen(value) + 2);
- strcpy(p, name);
+ valueLength = strlen(value);
+ p = ckalloc(nameLength + valueLength + 2);
+ memcpy(p, name, nameLength);
p[nameLength] = '=';
- strcpy(p+nameLength+1, value);
+ memcpy(p+nameLength+1, value, valueLength+1);
p2 = Tcl_UtfToExternalDString(NULL, p, -1, &envString);
/*
* Copy the native string to heap memory.
*/
- p = ckrealloc(p, strlen(p2) + 1);
- strcpy(p, p2);
+ p = ckrealloc(p, (unsigned) Tcl_DStringLength(&envString) + 1);
+ memcpy(p, p2, (unsigned) Tcl_DStringLength(&envString) + 1);
Tcl_DStringFree(&envString);
#ifdef USE_PUTENV
@@ -410,7 +412,8 @@ TclUnsetEnv(
Tcl_UtfToExternalDString(NULL, string, -1, &envString);
string = ckrealloc(string, (unsigned) Tcl_DStringLength(&envString)+1);
- strcpy(string, Tcl_DStringValue(&envString));
+ memcpy(string, Tcl_DStringValue(&envString),
+ (unsigned) Tcl_DStringLength(&envString)+1);
Tcl_DStringFree(&envString);
putenv(string);
@@ -566,7 +569,7 @@ EnvTraceProc(
const char *value = TclGetEnv(name2, &valueString);
if (value == NULL) {
- return "no such variable";
+ return (char *) "no such variable";
}
Tcl_SetVar2(interp, name1, name2, value, 0);
Tcl_DStringFree(&valueString);
@@ -720,8 +723,7 @@ TclCygwinPutenv(
/* Can't happen. */
return;
}
- *value = '\0';
- ++value;
+ *(value++) = '\0';
if (*value == '\0') {
value = NULL;
}
@@ -754,13 +756,13 @@ TclCygwinPutenv(
if (strcmp(name, "Path") == 0) {
#ifdef __WIN32__
- SetEnvironmentVariable("PATH", NULL);
+ SetEnvironmentVariableA("PATH", NULL);
#endif
unsetenv("PATH");
}
#ifdef __WIN32__
- SetEnvironmentVariable(name, value);
+ SetEnvironmentVariableA(name, value);
#endif
} else {
char *buf;
@@ -770,7 +772,7 @@ TclCygwinPutenv(
*/
#ifdef __WIN32__
- SetEnvironmentVariable("Path", NULL);
+ SetEnvironmentVariableA("Path", NULL);
#endif
unsetenv("Path");
@@ -785,7 +787,7 @@ TclCygwinPutenv(
}
#ifdef __WIN32__
- SetEnvironmentVariable(name, buf);
+ SetEnvironmentVariableA(name, buf);
#endif
}
}