[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 10/65] slirp: replace the poor-man string split with
From: |
Samuel Thibault |
Subject: |
[Qemu-devel] [PULL 10/65] slirp: replace the poor-man string split with g_strsplit() |
Date: |
Mon, 14 Jan 2019 23:52:11 +0100 |
From: Marc-André Lureau <address@hidden>
Use the glib function for the work, fix a potential crash on >256 words.
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Samuel Thibault <address@hidden>
---
slirp/misc.c | 21 +++------------------
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/slirp/misc.c b/slirp/misc.c
index ce323ef92e..4840187750 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -88,11 +88,8 @@ fork_exec(struct socket *so, const char *ex)
socklen_t addrlen = sizeof(addr);
socklen_t csaddrlen = sizeof(csaddr);
int opt;
- const char *argv[256];
- /* don't want to clobber the original */
- char *bptr;
- const char *curarg;
- int c, i, ret;
+ char **argv;
+ int ret;
pid_t pid;
DEBUG_CALL("fork_exec");
@@ -156,19 +153,7 @@ fork_exec(struct socket *so, const char *ex)
for (s = getdtablesize() - 1; s >= 3; s--)
close(s);
- i = 0;
- bptr = g_strdup(ex); /* No need to free() this */
- do {
- /* Change the string into argv[] */
- curarg = bptr;
- while (*bptr != ' ' && *bptr != (char)0)
- bptr++;
- c = *bptr;
- *bptr++ = (char)0;
- argv[i++] = g_strdup(curarg);
- } while (c);
-
- argv[i] = NULL;
+ argv = g_strsplit(ex, " ", -1);
execvp(argv[0], (char **)argv);
/* Ooops, failed, let's tell the user why */
--
2.20.1
- [Qemu-devel] [PULL 05/65] slirp: remove unused EMU_RSH, (continued)
- [Qemu-devel] [PULL 05/65] slirp: remove unused EMU_RSH, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 01/65] slirp: associate slirp_output callback with the Slirp context, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 04/65] slirp: use a dedicated field for chardev pointer, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 12/65] slirp: add tftp tracing, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 06/65] slirp: rename /extra/chardev, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 20/65] slirp: remove unused HAVE_SYS_BITYPES_H, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 19/65] slirp: remove HAVE_SYS_SIGNAL_H, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 15/65] slirp: use a callback structure to interface with qemu, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 16/65] slirp: remove PROBE_CONN dead-code, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 03/65] slirp: replace ex_pty with ex_chardev, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 10/65] slirp: replace the poor-man string split with g_strsplit(),
Samuel Thibault <=
- [Qemu-devel] [PULL 11/65] slirp: remove dead declarations, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 07/65] slirp: move internal function declarations, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 21/65] slirp: remove NO_UNIX_SOCKETS, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 22/65] slirp: remove unused HAVE_SYS_STROPTS_H, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 30/65] slirp: replace HOST_WORDS_BIGENDIAN with glib equivalent, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 18/65] slirp: remove the disabled readv()/writev() code path, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 17/65] slirp: remove FULL_BOLT, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 08/65] slirp: remove Monitor dependency, return a string for info, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 25/65] slirp: remove unused HAVE_SYS_SELECT_H, Samuel Thibault, 2019/01/14
- [Qemu-devel] [PULL 23/65] slirp: remove unused HAVE_ARPA_INET_H, Samuel Thibault, 2019/01/14