fix #199: encapsulate capture filename, to avoid problems with spaces in the filename (win32 only)

svn path=/trunk/; revision=14432
This commit is contained in:
Ulf Lamping 2005-05-25 17:46:04 +00:00
parent d22b1f3cbe
commit fbe12a9a22
1 changed files with 16 additions and 5 deletions

View File

@ -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