summaryrefslogtreecommitdiffstats
path: root/logic/minecraft
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-03-28 20:52:14 +0200
committerPetr Mrázek <peterix@gmail.com>2016-03-28 20:52:14 +0200
commit53b4bd019fe6b34559da1ce9c92533c9f79301ac (patch)
tree2673f44ed5a46fcc7670b87277ff96d2847fbffc /logic/minecraft
parentf032e32133023ed8396fc2b6ead7eadc2816a25b (diff)
downloadMultiMC-53b4bd019fe6b34559da1ce9c92533c9f79301ac.tar
MultiMC-53b4bd019fe6b34559da1ce9c92533c9f79301ac.tar.gz
MultiMC-53b4bd019fe6b34559da1ce9c92533c9f79301ac.tar.lz
MultiMC-53b4bd019fe6b34559da1ce9c92533c9f79301ac.tar.xz
MultiMC-53b4bd019fe6b34559da1ce9c92533c9f79301ac.zip
NOISSUE fix bug in unpacking of forge pack200 jar files
This caused failed downloads and broken files to be used.
Diffstat (limited to 'logic/minecraft')
-rw-r--r--logic/minecraft/forge/ForgeXzDownload.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/logic/minecraft/forge/ForgeXzDownload.cpp b/logic/minecraft/forge/ForgeXzDownload.cpp
index 2a47bb26..adf96552 100644
--- a/logic/minecraft/forge/ForgeXzDownload.cpp
+++ b/logic/minecraft/forge/ForgeXzDownload.cpp
@@ -143,6 +143,7 @@ void ForgeXzDownload::downloadReadyRead()
#include "xz.h"
#include "unpack200.h"
#include <stdexcept>
+#include <unistd.h>
const size_t buffer_size = 8196;
@@ -275,7 +276,14 @@ void ForgeXzDownload::decompressAndInstall()
failAndTryNextMirror();
return;
}
- FILE * file_in = fdopen(handle_in,"r");
+ int handle_in_dup = dup (handle_in);
+ if(handle_in_dup == -1)
+ {
+ qCritical() << "Error reopening " << pack200_file.fileName();
+ failAndTryNextMirror();
+ return;
+ }
+ FILE *file_in = fdopen (handle_in_dup, "rb");
if(!file_in)
{
qCritical() << "Error reopening " << pack200_file.fileName();
@@ -296,7 +304,14 @@ void ForgeXzDownload::decompressAndInstall()
failAndTryNextMirror();
return;
}
- FILE * file_out = fdopen(handle_out,"w");
+ int handle_out_dup = dup (handle_out);
+ if(handle_out_dup == -1)
+ {
+ qCritical() << "Error reopening " << qfile_out.fileName();
+ failAndTryNextMirror();
+ return;
+ }
+ FILE *file_out = fdopen (handle_out_dup, "wb");
if(!file_out)
{
qCritical() << "Error opening " << qfile_out.fileName();
@@ -305,6 +320,7 @@ void ForgeXzDownload::decompressAndInstall()
}
try
{
+ // NOTE: this takes ownership of both FILE pointers. That's why we duplicate them above.
unpack_200(file_in, file_out);
}
catch (std::runtime_error &err)