keymanapp / keymanapp/keyman

bug(windows): sfx archives generated for Keyman are probably technically invalid

Open
#8,685 0 comments 0 reactions 0 assignees View on GitHub
bug windows/
Dominant language
Pascal
Stars
534
Forks
143
Avg merge
2d 10h
Merged PRs (30d)
113

Description

Per comments from https://quality.embarcadero.com/browse/RSP-17889 (copied here for ref):

* ZIP archive contains offsets relative to beginning of stream/file. So:

```
CreateZip('example.zip', ParamStr(0)) - example.zip is created with offsets relative to beginning of example.zip, OK
UnzipZip('example.zip') - OK
CreateSfx(ParamStr(0), 'example.zip', 'example-zip.exe', offset) - example-zip.exe is created with appended example.zip, but the offsets are not updated, NOT CORRECT
UnzipZipAtOffset('example-zip.exe', offset) - example.zip is extracted and copied to TMemoryStream, then extracted, OK
UnzipSfx('example-zip.exe', offset) - trying to extract from some offset fails, because ZIP archive offsets are relative to beginning of stream, not to current stream position, FAIL
```

The main difference is how to create "sfx":

* 1st copy EXE to output stream
* then create ZIP archive using the same output stream

Note, using `TProxySubrangeStream` it is possible to embed / extract ZIP archive at some not-zero stream position without copying ZIP archive into another stream / file, eg:

```
TProxySubrangeStream.Create(InputStream, InputStream.Position, -1, False)
```

Given things are 'working' for now we will leave this at present. But something to check in on in the future.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.