diff options
| author | Karel Klic <kklic@redhat.com> | 2011-03-09 16:49:41 +0100 |
|---|---|---|
| committer | Karel Klic <kklic@redhat.com> | 2011-03-09 16:58:28 +0100 |
| commit | 43d84e3f11e46b7c9a042ff338024dfc41bb4f22 (patch) | |
| tree | 783b1122556f15345290ff8b1623812b6e864827 /src/include/xfuncs.h | |
| parent | 6ec12db137f2d0fe18f059fcef2390512d0b2c3f (diff) | |
| parent | c2f2a9f310e7b3bc3725cc8dc7e805fd38c7fbbd (diff) | |
Merge branch 'master' of ssh://git.fedorahosted.org/git/abrt
Diffstat (limited to 'src/include/xfuncs.h')
| -rw-r--r-- | src/include/xfuncs.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/include/xfuncs.h b/src/include/xfuncs.h index 61188c81..5f2504b6 100644 --- a/src/include/xfuncs.h +++ b/src/include/xfuncs.h @@ -74,6 +74,19 @@ char* xasprintf(const char *format, ...); #define xsetenv abrt_xsetenv void xsetenv(const char *key, const char *value); +/* + * Utility function to unsetenv a string which was possibly putenv'ed. + * The problem here is that "natural" optimization: + * strchrnul(var_val, '=')[0] = '\0'; + * unsetenv(var_val); + * is BUGGY: if string was put into environment via putenv, + * its modification (s/=/NUL/) is illegal, and unsetenv will fail to unset it. + * Of course, saving/restoring the char wouldn't work either. + * This helper creates a copy up to '=', unsetenv's it, and frees: + */ +#define safe_unsetenv abrt_safe_unsetenv +void safe_unsetenv(const char *var_val); + #define xsocket abrt_xsocket int xsocket(int domain, int type, int protocol); #define xbind abrt_xbind |
