From: Andre Noll Date: Sun, 19 Jul 2009 12:16:56 +0000 (+0200) Subject: Merge branch 'master' into next X-Git-Tag: v0.4.0~50^2~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=ad6c68022eea0b0962855a2120cf242446bf10b9;hp=-c Merge branch 'master' into next --- ad6c68022eea0b0962855a2120cf242446bf10b9 diff --combined alsa_write.c index 3c7c03b4,1e446093..ae8bed6d --- a/alsa_write.c +++ b/alsa_write.c @@@ -12,7 -12,6 +12,7 @@@ * based on the vplay program by Michael Beck. */ +#include #include #include #include @@@ -264,4 -263,5 +264,5 @@@ void alsa_write_init(struct writer *w .short_help = alsa_write_args_info_help, .detailed_help = alsa_write_args_info_detailed_help }; + alsa_cmdline_parser_free(&dummy); } diff --combined file_write.c index 3286ea87,e03cf8f6..9a4f0707 --- a/file_write.c +++ b/file_write.c @@@ -6,10 -6,8 +6,10 @@@ /** \file file_write.c simple output plugin for testing purposes */ +#include #include #include +#include #include "para.h" #include "list.h" @@@ -29,37 -27,20 +29,37 @@@ struct private_file_write_data int check_fd; }; +/* + * Get a random filename. + * + * This is by no means a secure way to create temporary files in a hostile + * directory like \p /tmp. However, we use it only for creating temp files in + * ~/.paraslash, for which it is OK. Result must be freed by the caller. + */ +__must_check __malloc static char *random_filename(void) +{ + char *result, *home = para_homedir(); + struct timeval tv; + + gettimeofday(&tv, NULL); + srandom(tv.tv_usec); + result = make_message("%s/.paraslash/%08lu", home, + para_random(99999999)); + free(home); + return result; +} + static int file_write_open(struct writer_node *wn) { struct private_file_write_data *pfwd = para_calloc( sizeof(struct private_file_write_data)); struct file_write_args_info *conf = wn->conf; char *filename; + if (conf->filename_given) filename = conf->filename_arg; - else { - char *tmp = para_tmpname(), *home = para_homedir(); - filename = make_message("%s/.paraslash/%s", home, tmp); - free(home); - free(tmp); - } + else + filename = random_filename(); wn->private_data = pfwd; pfwd->fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR); if (!conf->filename_given) @@@ -142,4 -123,5 +142,5 @@@ void file_write_init(struct writer *w .short_help = file_write_args_info_help, .detailed_help = file_write_args_info_detailed_help }; + file_cmdline_parser_free(&dummy); } diff --combined oss_write.c index 103b14ea,6a55005e..9ec85560 --- a/oss_write.c +++ b/oss_write.c @@@ -6,7 -6,6 +6,7 @@@ /** \file oss_write.c Paraslash's oss output plugin. */ +#include #include #include #include @@@ -217,4 -216,5 +217,5 @@@ void oss_write_init(struct writer *w .short_help = oss_write_args_info_help, .detailed_help = oss_write_args_info_detailed_help }; + oss_cmdline_parser_free(&dummy); }