-
Notifications
You must be signed in to change notification settings - Fork 977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra IDs larger than short.MaxValue
not supported in ZipExtraData
#657
Comments
Yeah, this seems like an overthought (or the problem just hasn't surfaced, so there were no incentive to support it before?)
Indeed, the Extra ID is defined as |
short.MaxValue
not supported in ZipExtraData
I think I hit that size issue when looking at #470 , though that change hasn't gone anywhere further. |
The only reason I can think of why this wasn't done before is using |
Should be fixed as per #669. |
Steps to reproduce
0xe57a
by implementingTaggedData
.ZipExtraData.AddEntry
method.Please refer to the source code of the program to reproduce this problem.
Expected behavior
The extra field is successfully added to the
ZipExtraData
object. Then I can refer to the extra field using something like theZipExtraData.GetData
method.Actual behavior
In the
ZipExtraData.AddEntry
method, aSystem.ArgumentOutOfRangeException
exception occurs.Version of SharpZipLib
SharpZipLib 1.3.2
Obtained from (only keep the relevant lines)
Supplementary information
Some explanation is needed as to why this problem occurred.
What I originally wanted to do was parse an unfamiliar extra field with a tag ID of
0xe57a
. I found the tag in the ZIP file I have.The specification of the tag is unclear, but according to "https://gnqg.hatenablog.com/entry/2016/09/11/155033", it seems to explicitly specify the code page of the entry name. It seems to have been used in an application called "ALZip" in the past.
Anyway, I wrote the code to try to get
0xe57a
extra field from that ZIP file. However, even thoughZipEntry.ExtraData
contains that extra field, for some reason theZipExtraData.GetData
method returns null.I thought it was weird and tried to write a sample program to fix the problem, but in fact I got an exception in
ZipExtraData.AddEntry
which was executed before theZipExtraData.GetData
method.I read the source code of
SharpZipLib/src/ICSharpCode.SharpZipLib/Zip/ZipExtraData.cs
.As a result, it seemed that
ZipExtraData.AddEntry
would raise an exception ifITaggedData.TagID
returned a value greater than or equal to0x8000
.Also, the reason why the
ZipExtraData.GetData
method returned null is that the value ofITaggedData.TagID
was expanded toint
and treated as a negative value (0xffffe57a
), and theReadShortInternal
method I think that the cause is that when reading the tag ID from the byte array, the operation is performed as an unsigned integer and the value (0x0000e57a
) is returned as anint
type.And the next thing to think about is, "Is a 16-bit integer greater than or equal to 0x8000 valid as a tag ID?"
I think that "a 16-bit integer of 0x8000 or more is also valid as a tag ID" for the following reasons.
proginfo/extrald.txt
) contains0xfb4a (SMS / QDOS)
.0x0000
to0x7fff
or whether it should be treated as a signed integer. (Maybe I just don't know y well ...)Source code of sample program
The text was updated successfully, but these errors were encountered: