summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2022-11-16 12:49:19 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-11-20 08:28:49 +0000
commit6edf38add3c20c44efe0588e2815bb280d22e0c4 (patch)
tree6918d6d5d92db66313c94f501dc5cd26fe96cf57 /meta/recipes-devtools
parent735ec126ec219c7cb89cb05b0e433201bb7f59eb (diff)
downloadopenembedded-core-6edf38add3c20c44efe0588e2815bb280d22e0c4.tar.gz
qemu-helper-native: Correctly pass program name as argv[0]
The previous version of this wasn't correctly passing the program name as argv[0], and was also over-complicated anyway because argv[] is guaranteed to be terminated with a NULL pointer, so it can be passed directly to the execv'd process without needing to be copied. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c b/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c
index cadf2a012a..9434e1d269 100644
--- a/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c
+++ b/meta/recipes-devtools/qemu/qemu-helper/qemu-oe-bridge-helper.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <unistd.h>
+#include <stdlib.h>
void try_program(char const* path, char** args) {
if (access(path, X_OK) == 0) {
@@ -18,22 +19,14 @@ void try_program(char const* path, char** args) {
int main(int argc, char** argv) {
char* var;
- /* Copy arguments so that they are a NULL terminated list, skipping argv[0]
- * since it is this program name */
- char** args = malloc(argc * sizeof(char*));
- for (int i = 0; i < argc - 1; i++) {
- args[i] = argv[i + 1];
- }
- args[argc - 1] = NULL;
-
var = getenv("QEMU_BRIDGE_HELPER");
if (var && var[0] != '\0') {
- execvp(var, args);
+ execvp(var, argv);
return 1;
}
- try_program("/usr/libexec/qemu-bridge-helper", args);
- try_program("/usr/lib/qemu/qemu-bridge-helper", args);
+ try_program("/usr/libexec/qemu-bridge-helper", argv);
+ try_program("/usr/lib/qemu/qemu-bridge-helper", argv);
fprintf(stderr, "No bridge helper found\n");
return 1;