[libc-commits] [libc] [libc][stdlib] Add putenv (PR #208339)

Pavel Labath via libc-commits libc-commits at lists.llvm.org
Thu Jul 9 00:00:32 PDT 2026


https://github.com/labath commented:

I have to say I am wondering if we really need this rejection of the `=bar` entries. I can find many arguments against it, and not very much for it:
- it's not consistent with glibc, which lets you call `putenv("=bar")`.
- it's kind of a natural extension of the `$foo=$bar` syntax (an empty string is still a string)
- It doesn't buy us much in terms of safety, as the user has other ways of getting this string into the environment:
  - direct `environ` manipulation
  - `execve`
  - sneakily modifying the provided string after we insert it into the environment
  - heck, even `env` will let you do that:
    ```
    $ env - =bar env
    =bar
    ```

The only argument I find for this is that it is consistent with `putenv` and `getenv`, which (but in llvm libc and glibc) refuse to operate on the empty string. But, if consistency is what we're after, I might actually argue to drop the empty string check from those functions as well. :P

After reading this, do you still want to keep the check?

https://github.com/llvm/llvm-project/pull/208339


More information about the libc-commits mailing list