From 20d4cbd608efc76cb6a3332620ba6fabf228f92f Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 30 Sep 2007 21:26:25 +0000 Subject: [PATCH] Disallowed --read_and_print raw:- , allowed to write to chardev+pipe+socket --- libburn/trunk/test/telltoc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libburn/trunk/test/telltoc.c b/libburn/trunk/test/telltoc.c index 15e610c3..cd37ec53 100644 --- a/libburn/trunk/test/telltoc.c +++ b/libburn/trunk/test/telltoc.c @@ -147,7 +147,6 @@ int telltoc_aquire_by_adr(char *drive_adr) burn_drive_info_free(test_drive_list); */ - return ret; } @@ -620,8 +619,13 @@ int telltoc_read_and_print(struct burn_drive *drive, return -1; if (encoding == 1) { if (stat(raw_file,&stbuf) != -1) { - fprintf(stderr,"SORRY: target file '%s' already existing\n", raw_file); - return 1; + if (!(S_ISCHR(stbuf.st_mode) || S_ISFIFO(stbuf.st_mode) + || (stbuf.st_mode & S_IFMT) == S_IFSOCK )) { + fprintf(stderr, + "SORRY: target file '%s' already existing\n", + raw_file); + return 1; + } } raw_fp = fopen(raw_file,"w"); if (raw_fp == NULL) { @@ -767,6 +771,11 @@ int telltoc_setup(int argc, char **argv) if(strncmp(argv[i], "raw:", 4) == 0 || strcmp(argv[i],"1:") == 0) { print_encoding = 1; strcpy(print_raw_file, strchr(argv[i], ':') + 1); + if (strcmp(print_raw_file, "-") == 0) { + fprintf(stderr, + "--read_and_print does not write to \"-\" as stdout.\n"); + return 1; + } } else if(strcmp(argv[i], "hex") == 0 || strcmp(argv[i], "2") == 0) print_encoding = 2;