From c9548bb8272ffe5804085f0a7a9f19305f0d513b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 2 Jan 2018 15:07:29 +0000 Subject: Fix opening of ZIP files of certificates on Windows (#1124). --- src/lib/internet.cc | 21 +++++++++++++++++---- src/lib/scoped_temporary.cc | 9 +++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/lib/internet.cc b/src/lib/internet.cc index aafdf3a83..1e8c5d8e9 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -21,6 +21,7 @@ #include "scoped_temporary.h" #include "compose.hpp" #include "exceptions.h" +#include "cross.h" #include #include #include @@ -78,13 +79,23 @@ get_from_zip_url (string url, string file, bool pasv, function (_("Could not open downloaded ZIP file")); + } + + zip_source_t* zip_source = zip_source_filep_create (zip_file, 0, -1, 0); + if (!zip_source) { + return optional (_("Could not open downloaded ZIP file")); + } + + zip_t* zip = zip_open_from_source (zip_source, 0, 0); if (!zip) { return optional (_("Could not open downloaded ZIP file")); } - struct zip_file* zip_file = zip_fopen (zip, file.c_str(), 0); - if (!zip_file) { + struct zip_file* file_in_zip = zip_fopen (zip, file.c_str(), 0); + if (!file_in_zip) { return optional (_("Unexpected ZIP file contents")); } @@ -92,12 +103,14 @@ get_from_zip_url (string url, string file, bool pasv, function + Copyright (C) 2012-2018 Carl Hetherington This file is part of DCP-o-matic. @@ -19,6 +19,8 @@ */ #include "scoped_temporary.h" +#include "exceptions.h" +#include "cross.h" /** Construct a ScopedTemporary. A temporary filename is decided but the file is not opened * until open() is called. @@ -51,7 +53,10 @@ FILE* ScopedTemporary::open (char const * params) { close (); - _open = fopen (c_str(), params); + _open = fopen_boost (_file, params); + if (!_open) { + throw FileError ("Could not open scoped temporary", _file); + } return _open; } -- cgit v1.2.3