Re: [LINUX] ENV VAR addresses



pater <pater.catania1946@xxxxxxxxx> writes:
Following a book, i read that the address of the environment variables
depends on the program name... and it won't change until u change it.

Making some tries, on my ubuntu, i found out that it changes every
time i execute the program. So, there's no way to predict what
addresses the env vars would take?

I need these infos cuz i need to put datas in the stack to be easily
picked up by the program itself, without using getenv, only with an
address.

The C standard itself doesn't say much about environment variables.
It defines the getenv() function, which returns a pointer to a string
containing the value of a specified environment variable. C doesn't
even guarantee that getenv("FOO") will return the same address when
you call it twice in a row.

Generally, *no* addresses are going to be consistent from one
execution of a program to another.

Since your question appears to be specific to Unix-like systems, I
suggest asking in comp.unix.programmer. When you do, you should be
more specific about your requirements; based on what you've written, I
can't figure out what you're trying to do.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • ENV VAR addresses
    ... i read that the address of the environment variables ... Making some tries, on my ubuntu, i found out that it changes every ... time i execute the program. ... addresses the env vars would take? ...
    (comp.unix.programmer)
  • [NEWS] MacOS X TruBlueEnvironment Privilege Escalation Attack
    ... TruBlueEnvironment is part of the MacOS Classic Emulator. ... By setting certain environment variables, ... run automatically via cron. ... remove global execute permissions from the TruBlueEnvironment executable, ...
    (Securiteam)
  • Re: Korn and csh variables issue
    ... korn shell and C shell? ... You could define them as environment variables, and THEN execute the shell. ... setvar a 123 ...
    (comp.unix.shell)
  • Re: Fix for memory leak in setenv/unsetenv
    ... the first active variable found is returned by getenv() even ... then a search by getenvfrom the end of the array backwards would be ... > values of environment variables would result in nearly reasonable ... have things such as memory allocation and an environment (such as I have ...
    (freebsd-current)
  • Re: Syscall problem ?
    ... >>calling the getenv function' ... Suppose FOO and BAR are both the names of environment variables. ...
    (comp.std.c)

Loading