X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/bfe645c1570343d3adca657ab67998e122ca8792..f3c73adaa541ae54092467a29668ac32894ef1dc:/src/src/setenv.c diff --git a/src/src/setenv.c b/src/src/setenv.c index 6da56d58d..9a05b64b9 100644 --- a/src/src/setenv.c +++ b/src/src/setenv.c @@ -2,15 +2,16 @@ * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) Michael Haardt 2015 */ -/* Copyright (c) Jeremy Harris 2015 */ +/* Copyright (c) Michael Haardt 2015 + * Copyright (c) Jeremy Harris 2015 - 2016 + * Copyright (c) The Exim Maintainers 2016 */ /* See the file NOTICE for conditions of use and distribution. */ /* This module provides (un)setenv routines for those environments -lacking them in libraries. */ +lacking them in libraries. It is #include'd by OS/os.c-foo files. */ -static int +int setenv(const char * name, const char * val, int overwrite) { uschar * s; @@ -20,12 +21,11 @@ if (overwrite || !getenv(name)) return 0; } -static int +int unsetenv(const char *name) { size_t len; const char * end; -char ** e; extern char ** environ; if (!name) @@ -34,13 +34,16 @@ if (!name) return -1; } +if (!environ) + return 0; + for (end = name; *end != '=' && *end; ) end++; len = end - name; /* Find name in environment and move remaining variables down. Do not early-out in case there are duplicate names. */ -for (e = environ; *e; e++) +for (char ** e = environ; *e; e++) if (strncmp(*e, name, len) == 0 && (*e)[len] == '=') { char ** sp = e;