Skip to content

Fix temporary archive init in Zippy::ZipArchive::Save#210

Closed
punk-floyd wants to merge 1 commit into
troldal:masterfrom
punk-floyd:topic/fix-ZippyTempArchive
Closed

Fix temporary archive init in Zippy::ZipArchive::Save#210
punk-floyd wants to merge 1 commit into
troldal:masterfrom
punk-floyd:topic/fix-ZippyTempArchive

Conversation

@punk-floyd
Copy link
Copy Markdown

On branch topic/fix-ZippyTempArchive
Changes to be committed:
modified: OpenXLSX/external/zippy/zippy.hpp

  • Fixed a bug in the generation of the pathname for a temporary archive used during a save operation. The implementation was peeling out the path by searching for the last '/', but Windows-based systems generally use ''. The net result is that the temporary file is created in the current directory instead of the directory of the existing archive. If the current directory happens to be a 'protected' directory (such as the standard Program Files directories) then the file creation will fail.
  • In the scenario above, the failure to create the temporary archive was not caught, resulting in the code proceeding and eventually failing, but without any error information attached. The fix, included here, is to check the return value of mz_zip_writer_init_file and throw if it fails.

 On branch topic/fix-ZippyTempArchive
 Changes to be committed:
	modified:   OpenXLSX/external/zippy/zippy.hpp

+ Fixed a bug in the generation of the pathname for a temporary archive used
  during a save operation. The implementation was peeling out the path by
  searching for the last '/', but Windows-based systems generally use '\'.
  The net result is that the temporary file is created in the current
  directory instead of the directory of the existing archive. If the current
  directory happens to be a 'protected' directory (such as the standard
  Program Files directories) then the file creation will fail.
+ In the scenario above, the failure to create the temporary archive was
  not caught, resulting in the code proceeding and eventually failing, but
  without any error information attached. The fix, included here, is to
  check the return value of mz_zip_writer_init_file and throw if it fails.
@aral-matrix
Copy link
Copy Markdown
Collaborator

This pull request has been implemented manually in the May 2024 Update.

If you could check this, but basically all backslashes in a (windows) path are now replaced by forward slashes, which work fine with C++ fopen etc.
The ZipRuntimeError exception has been implemented as suggested.

@aral-matrix aral-matrix added the superseded Pull request has been superseded by changes or was implemented manually into the main branch label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

superseded Pull request has been superseded by changes or was implemented manually into the main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants