[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v2 6/6] linux-user: Add '-native-bypass' option
From: |
Manos Pitsidianakis |
Subject: |
Re: [RFC v2 6/6] linux-user: Add '-native-bypass' option |
Date: |
Fri, 09 Jun 2023 08:24:42 +0300 |
User-agent: |
meli 0.7.2 |
On Wed, 07 Jun 2023 19:47, Yeqi Fu <fufuyqqqqqq@gmail.com> wrote:
--- a/linux-user/main.c
+++ b/linux-user/main.c
+ /* Set the library for native bypass */
+ if (native_lib != NULL) {
+ char *token = malloc(strlen(native_lib) + 12);
malloc() can fail (in rare circumstances). Check for the return value
here. Or use g_malloc() which terminates on alloc failure.
+ strcpy(token, "LD_PRELOAD=");
+ strcat(token, native_lib);
(You could alternatively use snprintf() here)
diff --git a/util/envlist.c b/util/envlist.c
index db937c0427..713d52497e 100644
+int
+envlist_appendenv(envlist_t *envlist, const char *env, const char *separator)
+{
+ struct envlist_entry *entry = NULL;
+ const char *eq_sign;
+ size_t envname_len;
+
+ if ((envlist == NULL) || (env == NULL)) {
separator must not be NULL as well.
+ return (EINVAL);
Unnecessary parentheses here and in later returns.
+ }
+
+ /* find out first equals sign in given env */
+ eq_sign = strchr(env, '=');
+ if (eq_sign == NULL) {
Perhaps you can return an error message to the user here also, and
explain why it failed. You can do that by passing an error message
pointer with the function arguments.
By the way, if strchr(strchr(env, '='), '=') != NULL, shouldn't this
fail also?
- [RFC v2 3/6] target/i386: Add native library calls, (continued)
- [RFC v2 3/6] target/i386: Add native library calls, Yeqi Fu, 2023/06/07
- [RFC v2 1/6] build: Add configure options for native calls, Yeqi Fu, 2023/06/07
- [RFC v2 5/6] target/arm: Add native library calls, Yeqi Fu, 2023/06/07
- [RFC v2 2/6] Add the libnative library, Yeqi Fu, 2023/06/07
- [RFC v2 6/6] linux-user: Add '-native-bypass' option, Yeqi Fu, 2023/06/07
- [RFC v2 4/6] target/mips: Add native library calls, Yeqi Fu, 2023/06/07