From fbe12a9a229bd3c815e8719fc318072cf19d820b Mon Sep 17 00:00:00 2001 From: Ulf Lamping Date: Wed, 25 May 2005 17:46:04 +0000 Subject: [PATCH] fix #199: encapsulate capture filename, to avoid problems with spaces in the filename (win32 only) svn path=/trunk/; revision=14432 --- capture_sync.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/capture_sync.c b/capture_sync.c index 16fe008c57..d0a5feb91f 100644 --- a/capture_sync.c +++ b/capture_sync.c @@ -328,6 +328,7 @@ sync_pipe_start(capture_options *capture_opts) { char signal_pipe_fd[ARGV_NUMBER_LEN]; char *fontstring; char *filterstring; + char *savefilestring; int signal_pipe[2]; /* pipe used to send messages from parent to child (currently only stop) */ #else char errmsg[1024+1]; @@ -355,11 +356,6 @@ sync_pipe_start(capture_options *capture_opts) { argv = sync_pipe_add_arg(argv, &argc, "-i"); argv = sync_pipe_add_arg(argv, &argc, capture_opts->iface); - if(capture_opts->save_file) { - argv = sync_pipe_add_arg(argv, &argc, "-w"); - argv = sync_pipe_add_arg(argv, &argc, capture_opts->save_file); - } - if (capture_opts->has_snaplen) { argv = sync_pipe_add_arg(argv, &argc, "-s"); sprintf(ssnap,"%d",capture_opts->snaplen); @@ -475,12 +471,22 @@ sync_pipe_start(capture_options *capture_opts) { argv = sync_pipe_add_arg(argv, &argc, filterstring); } + /* Convert save file name to a quote delimited string and pass to child */ + if(capture_opts->save_file) { + argv = sync_pipe_add_arg(argv, &argc, "-w"); + savefilestring = sync_pipe_quote_encapsulate(capture_opts->save_file); + argv = sync_pipe_add_arg(argv, &argc, savefilestring); + } + /* Spawn process */ capture_opts->fork_child = spawnvp(_P_NOWAIT, ethereal_path, argv); g_free(fontstring); if (filterstring) { g_free(filterstring); } + if(savefilestring) { + g_free(savefilestring); + } /* child own's the read side now, close our handle */ close(signal_pipe[PIPE_READ]); @@ -501,6 +507,11 @@ sync_pipe_start(capture_options *capture_opts) { argv = sync_pipe_add_arg(argv, &argc, capture_opts->cfilter); } + if(capture_opts->save_file) { + argv = sync_pipe_add_arg(argv, &argc, "-w"); + argv = sync_pipe_add_arg(argv, &argc, capture_opts->save_file); + } + if ((capture_opts->fork_child = fork()) == 0) { /* * Child process - run Ethereal with the right arguments to make