Bug 776516 - Saving over existing GZ or BZ2 compressed files...

...does not truncate them

Pass O_TRUNC to g_open() when creating the target files.
This commit is contained in:
Michael Natterer 2017-01-03 15:10:35 +01:00
parent 8111ad62da
commit 559a758581
1 changed files with 2 additions and 2 deletions

View File

@ -640,7 +640,7 @@ gzip_save (const char *infile,
if (!in)
goto out;
fd = g_open (outfile, O_CREAT | O_WRONLY | _O_BINARY, 0664);
fd = g_open (outfile, O_CREAT | O_WRONLY | O_TRUNC | _O_BINARY, 0664);
if (fd == -1)
goto out;
@ -762,7 +762,7 @@ bzip2_save (const char *infile,
if (!in)
goto out;
fd = g_open (outfile, O_CREAT | O_WRONLY | _O_BINARY, 0664);
fd = g_open (outfile, O_CREAT | O_WRONLY | O_TRUNC | _O_BINARY, 0664);
if (fd == -1)
goto out;