projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cmd_config: replace action magic numbers with enum
[tinc]
/
src
/
script.c
diff --git
a/src/script.c
b/src/script.c
index
cb3d293
..
0b16c86
100644
(file)
--- a/
src/script.c
+++ b/
src/script.c
@@
-37,12
+37,12
@@
static void unputenv(const char *p) {
ptrdiff_t len = e - p;
#ifndef HAVE_UNSETENV
ptrdiff_t len = e - p;
#ifndef HAVE_UNSETENV
-#ifdef HAVE_
MINGW
+#ifdef HAVE_
WINDOWS
// Windows requires putenv("FOO=") to unset %FOO%
len++;
#endif
#endif
// Windows requires putenv("FOO=") to unset %FOO%
len++;
#endif
#endif
- char
var[len + 1]
;
+ char
*var = alloca(len + 1)
;
strncpy(var, p, len);
var[len] = 0;
#ifdef HAVE_UNSETENV
strncpy(var, p, len);
var[len] = 0;
#ifdef HAVE_UNSETENV
@@
-148,7
+148,7
@@
bool execute_script(const char *name, environment_t *env) {
/* First check if there is a script */
/* First check if there is a script */
-#ifdef HAVE_
MINGW
+#ifdef HAVE_
WINDOWS
if(!*scriptextension) {
const char *pathext = getenv("PATHEXT");
if(!*scriptextension) {
const char *pathext = getenv("PATHEXT");
@@
-159,9
+159,11
@@
bool execute_script(const char *name, environment_t *env) {
size_t pathlen = strlen(pathext);
size_t scriptlen = strlen(scriptname);
size_t pathlen = strlen(pathext);
size_t scriptlen = strlen(scriptname);
- char fullname[scriptlen + pathlen + 1];
+
+ const size_t fullnamelen = scriptlen + pathlen + 1;
+ char *fullname = alloca(fullnamelen);
char *ext = fullname + scriptlen;
char *ext = fullname + scriptlen;
- strncpy(fullname, scriptname,
sizeof(fullname)
);
+ strncpy(fullname, scriptname,
fullnamelen
);
const char *p = pathext;
bool found = false;
const char *p = pathext;
bool found = false;