summarylogtreecommitdiffstats
path: root/enca-bad-file-descriptor.patch
diff options
context:
space:
mode:
authorGordonGR2018-04-02 15:10:30 +0300
committerGordonGR2018-04-02 15:10:30 +0300
commitd61a02551e4d960544a726ff4d3eeb1761db7f9e (patch)
tree7305c863b4b789e2956fe44a91a354357107963f /enca-bad-file-descriptor.patch
parent8abc0d299539b76bba7720e20339119f38419b21 (diff)
downloadaur-d61a02551e4d960544a726ff4d3eeb1761db7f9e.tar.gz
1.19-2: Add patch for FS#57881
Diffstat (limited to 'enca-bad-file-descriptor.patch')
-rw-r--r--enca-bad-file-descriptor.patch35
1 files changed, 35 insertions, 0 deletions
diff --git a/enca-bad-file-descriptor.patch b/enca-bad-file-descriptor.patch
new file mode 100644
index 00000000000..2f6ad911bed
--- /dev/null
+++ b/enca-bad-file-descriptor.patch
@@ -0,0 +1,35 @@
+--- a/src/convert_recode.c
++++ b/src/convert_recode.c
+@@ -101,7 +101,8 @@ convert_recode(File *file,
+ return ERR_IOFAIL;
+ file->buffer->pos = 0;
+
+- if ((tempfile = file_temporary(file->buffer, 1)) == NULL
++ /* We do not unlink tempfile, because we want to reopen it later */
++ if ((tempfile = file_temporary(file->buffer, 0)) == NULL
+ || file_seek(file, 0, SEEK_SET) != 0) {
+ file_free(tempfile);
+ return ERR_IOFAIL;
+@@ -112,9 +113,20 @@ convert_recode(File *file,
+ task->fail_level = enca_recode_fail_level;
+ task->abort_level = RECODE_SYSTEM_ERROR;
+ task->input.name = NULL;
+- task->input.file = file->stream;
+ task->output.name = NULL;
+- task->output.file = tempfile->stream;
++ /* recode_perform_task closes given streams, so we need to duplicate them */
++ task->input.file = fopen(file->name, "rb");
++ if (task->input.file == NULL) {
++ fprintf(stderr, "failed to reopen `%s'\n", file->name);
++ file_free(tempfile);
++ return ERR_IOFAIL;
++ }
++ task->output.file = fopen(tempfile->name, "wb");
++ if (task->input.file == NULL) {
++ fprintf(stderr, "failed to reopen `%s'\n", tempfile->name);
++ file_free(tempfile);
++ return ERR_IOFAIL;
++ }
+
+ /* Now run conversion original -> temporary file. */
+ success = recode_perform_task(task);