[PATCH] crecord: truncate file to remove content of existing file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Without O_TRUNC overwriting bigger file by smaller one doesn't wipe the
old file fully.

Signed-off-by: Piotr Maziarz <piotrx.maziarz@xxxxxxxxxxxxxxx>
Signed-off-by: Cezary Rojewski <cezary.rojewski@xxxxxxxxx>
---
 src/utils/crecord.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/utils/crecord.c b/src/utils/crecord.c
index 12ad961..abaafea 100644
--- a/src/utils/crecord.c
+++ b/src/utils/crecord.c
@@ -323,7 +323,7 @@ static void capture_samples(char *name, unsigned int card, unsigned int device,
         if (!name) {
                 file = STDOUT_FILENO;
         } else {
-	        file = open(name, O_RDWR | O_CREAT,
+	        file = open(name, O_RDWR | O_CREAT | O_TRUNC,
 			    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
 	        if (file == -1) {
 		       fprintf(stderr, "Unable to open file '%s'\n", name);
-- 
2.7.4

_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux