Status: Accepted
Owner:
[hidden email]
Labels: Type-Defect Priority-Medium GLASS-Server Version-2.4.x
Milestone-1.0-beta.8 Package-Core
New issue 263 by
[hidden email]:
ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error
http://code.google.com/p/glassdb/issues/detail?id=263ZipFileMember>>#readLocalDirecotryFileHeaderFrom: (dated from 2007)
sets the position of the stream it is reading from to
'localHeaderRealtiveOffset + 1', however, this generates
an Off-by-one error. Also, compare the Squeak version (dated from 2005)
where no +1 is visible.
readLocalDirectoryFileHeaderFrom: aStream
"Positions stream as necessary. Will return stream to its original
position"
| fileNameLength extraFieldLength xcrc32 xcompressedSize xuncompressedSize
sig oldPos |
oldPos := aStream position.
aStream position: localHeaderRelativeOffset.
sig := aStream next: 4.
sig = LocalFileHeaderSignature asByteArray
ifFalse: [ aStream position: oldPos.
^self error: 'bad LH signature at ', localHeaderRelativeOffset
printStringHex ].
versionNeededToExtract := aStream nextLittleEndianNumber: 2.
bitFlag := aStream nextLittleEndianNumber: 2.
compressionMethod := aStream nextLittleEndianNumber: 2.
lastModFileDateTime := aStream nextLittleEndianNumber: 4.
xcrc32 := aStream nextLittleEndianNumber: 4.
xcompressedSize := aStream nextLittleEndianNumber: 4.
xuncompressedSize := aStream nextLittleEndianNumber: 4.
fileNameLength := aStream nextLittleEndianNumber: 2.
extraFieldLength := aStream nextLittleEndianNumber: 2.
fileName := (aStream next: fileNameLength) asString asSqueakPathName.
localExtraField := (aStream next: extraFieldLength) asByteArray.
dataOffset := aStream position.
"Don't trash these fields if we already got them from the central
directory"
self hasDataDescriptor ifFalse: [
crc32 := xcrc32.
compressedSize := xcompressedSize.
uncompressedSize := xuncompressedSize.
].
aStream position: oldPos.
Probably this is due to different Stream semantics? the Stream handed in is
an Ansi Stream.