projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove vendored LZ4
[tinc]
/
src
/
script.c
diff --git
a/src/script.c
b/src/script.c
index
81216a3
..
cb3d293
100644
(file)
--- a/
src/script.c
+++ b/
src/script.c
@@
-1,7
+1,7
@@
/*
script.c -- call an external script
Copyright (C) 1999-2005 Ivo Timmermans,
/*
script.c -- call an external script
Copyright (C) 1999-2005 Ivo Timmermans,
- 2000-20
17
Guus Sliepen <guus@tinc-vpn.org>
+ 2000-20
22
Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-35,7
+35,7
@@
static void unputenv(const char *p) {
return;
}
return;
}
-
in
t len = e - p;
+
ptrdiff_
t len = e - p;
#ifndef HAVE_UNSETENV
#ifdef HAVE_MINGW
// Windows requires putenv("FOO=") to unset %FOO%
#ifndef HAVE_UNSETENV
#ifdef HAVE_MINGW
// Windows requires putenv("FOO=") to unset %FOO%
@@
-50,7
+50,7
@@
static void unputenv(const char *p) {
#else
// We must keep what we putenv() around in memory.
// To do this without memory leaks, keep things in a list and reuse if possible.
#else
// We must keep what we putenv() around in memory.
// To do this without memory leaks, keep things in a list and reuse if possible.
- static list_t list = {};
+ static list_t list = {
0
};
for list_each(char, data, &list) {
if(!strcmp(data, var)) {
for list_each(char, data, &list) {
if(!strcmp(data, var)) {
@@
-80,7
+80,12
@@
int environment_add(environment_t *env, const char *format, ...) {
if(format) {
va_list ap;
va_start(ap, format);
if(format) {
va_list ap;
va_start(ap, format);
- vasprintf(&env->entries[env->n], format, ap);
+
+ if(vasprintf(&env->entries[env->n], format, ap) == -1) {
+ // Assume we are out of memory.
+ abort();
+ }
+
va_end(ap);
} else {
env->entries[env->n] = NULL;
va_end(ap);
} else {
env->entries[env->n] = NULL;
@@
-93,7
+98,11
@@
void environment_update(environment_t *env, int pos, const char *format, ...) {
free(env->entries[pos]);
va_list ap;
va_start(ap, format);
free(env->entries[pos]);
va_list ap;
va_start(ap, format);
- vasprintf(&env->entries[pos], format, ap);
+
+ if(vasprintf(&env->entries[pos], format, ap) == -1) {
+ abort();
+ }
+
va_end(ap);
}
va_end(ap);
}
@@
-142,7
+151,12
@@
bool execute_script(const char *name, environment_t *env) {
#ifdef HAVE_MINGW
if(!*scriptextension) {
#ifdef HAVE_MINGW
if(!*scriptextension) {
- const char *pathext = getenv("PATHEXT") ? : ".COM;.EXE;.BAT;.CMD";
+ const char *pathext = getenv("PATHEXT");
+
+ if(!pathext) {
+ pathext = ".COM;.EXE;.BAT;.CMD";
+ }
+
size_t pathlen = strlen(pathext);
size_t scriptlen = strlen(scriptname);
char fullname[scriptlen + pathlen + 1];
size_t pathlen = strlen(pathext);
size_t scriptlen = strlen(scriptname);
char fullname[scriptlen + pathlen + 1];