In my program I am using secure_getenv function to fetch some environment variables. I included stdlib.h in my program. This is the sample call to secure_getenv.
Line 1 : char *myenv;
Line 2 : myenv = __secure_getenv("DATA");
After the above lines execution, myenv points to some junk.
I tried this within gdb after line 2.
p __secure_getenv("DATA")
This prints me the DATA I wanted.
But when I try, "p myenv", It prints the below.
$2 = 0×fffffffffffffe13f<Address 0xfffffffffffffe13f out of bounds>"
Can the experts help me to understand what is missing & how to make this work.
Edited to add: How the myenv is actually used? In somepoint in time my code tries to call the below.
strlen(myenv);
On strlen function call, my code terminates with sig11(SIGSEGV)
myenvis actually used, and print it there.secure_getenv(). It uses__secure_getenv(), which I don't think is a documented interface or one intended to be accessed by user code.__secure_getenvyourself (or not using it after all), or unless you are actively suppressing compiler messages, it is highly unlikely that the compiler is accepting your code without emitting any diagnostics.