Skip to contentSkip to conversation

crecord: truncate file to remove content of existing file

PATCH New Piotr Maziarz 1 participant 1 message Nov 26, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crecord: truncate file to remove content of existing file

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

---
 src/utils/crecord.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/utils/crecord.c +1 -1
index 12ad961..abaafea 100644
@@ -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);
Signature · 6 lines
2.7.4

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel