/*
script.c -- call an external script
Copyright (C) 1999-2005 Ivo Timmermans,
- 2000-2018 Guus Sliepen <guus@tinc-vpn.org>
+ 2000-2022 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
return;
}
- int len = e - p;
+ ptrdiff_t len = e - p;
#ifndef HAVE_UNSETENV
#ifdef HAVE_MINGW
// Windows requires putenv("FOO=") to unset %FOO%
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;
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);
}