logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: 83990b76556d85e5dc0fc8914fda611ed83c3fa7
parent 5a8a7ba1a8fb059d9c82265e6eb371ebd3ad7e67
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat, 19 Feb 2022 00:19:19 +0100

bin/env: Clear scan-build warning on envclear dangling reference

env.c:82:4: warning: Address of stack memory associated with local variable 'envclear' is still referred to by the global variable 'environ' upon returning to the caller.  This will be a dangling reference [core.StackAddressEscape]
                        return 127;
                        ^~~~~~~~~~
env.c:94:3: warning: Address of stack memory associated with local variable 'envclear' is still referred to by the global variable 'environ' upon returning to the caller.  This will be a dangling reference [core.StackAddressEscape]
                return 127;
                ^~~~~~~~~~
env.c:97:2: warning: Address of stack memory associated with local variable 'envclear' is still referred to by the global variable 'environ' upon returning to the caller.  This will be a dangling reference [core.StackAddressEscape]
        return 0;
        ^~~~~~~~
3 warnings generated.

Diffstat:

Mbin/env.c5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/bin/env.c b/bin/env.c @@ -10,6 +10,7 @@ #include <unistd.h> // getopt, opt* extern char **environ; +char *envclear[1]; int export() { @@ -60,8 +61,8 @@ main(int argc, char *argv[]) if(flag_i) { - char *envclear[] = {NULL}; - environ = envclear; + environ = envclear; + envclear[0] = NULL; } for(; argv[0]; argv++, argc--)