env_dup: Fix copying of env between address environments

If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.

The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().

Obviously this is not needed for kernel processes.
This commit is contained in:
Ville Juven
2022-04-04 13:11:06 +03:00
committed by Xiang Xiao
parent 6b1ee4c2e2
commit 4c1b66246d
17 changed files with 133 additions and 46 deletions
+4
View File
@@ -138,7 +138,11 @@ void arc4random_buf(FAR void *bytes, size_t nbytes);
/* Environment variable support */
#ifdef CONFIG_DISABLE_ENVIRON
# define get_environ_ptr() NULL
#else
FAR char **get_environ_ptr(void);
#endif
FAR char *getenv(FAR const char *name);
int putenv(FAR const char *string);
int clearenv(void);