Page MenuHomeFreeBSD

libc: Add getenv_r() function.
AcceptedPublic

Authored by des on Wed, Apr 23, 12:23 PM.
Tags
None
Referenced Files
F115449757: D49979.id.diff
Wed, Apr 23, 11:27 PM
F115427190: D49979.id154159.diff
Wed, Apr 23, 5:16 PM
F115425252: D49979.id.diff
Wed, Apr 23, 4:41 PM
F115425153: D49979.id154159.diff
Wed, Apr 23, 4:39 PM
F115423463: D49979.diff
Wed, Apr 23, 4:09 PM
F115423394: D49979.diff
Wed, Apr 23, 4:08 PM

Details

Reviewers
kevans
Group Reviewers
Klara
Summary

This is a calque of the NetBSD function of the same name.

MFC after: never
Relontes: yes
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63668
Build 60552: arc lint + arc unit

Event Timeline

des requested review of this revision.Wed, Apr 23, 12:23 PM
kevans added a subscriber: kevans.

If you're up for it, adding _FORTIFY_SOURCE support for this would be nearly trivial. The __ssp_redirect pattern for arc4random_buf in include/ssp/stdlib.h can be copied for this (the __buf and __len names are significant and used in the implementation for size-checking, other names are fair game) and tests added easily by copying arc4random_buf again in lib/libc/tests/secure/generate-fortify-tests.lua (regeneration requires devel/lua-luacheck for make generate-tests).

This revision is now accepted and ready to land.Wed, Apr 23, 12:52 PM
markj added inline comments.
lib/libc/stdlib/getenv.c
475

Wouldn't it be more useful to somehow return the actual size of the variable? Userspace effectively has to guess and just double the size until getenv_r() succeeds.

lib/libc/stdlib/getenv.c
475

Worse, we copy to the buffer and return an error....