Issue 263 in glassdb: ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue 263 in glassdb: ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error

glassdb
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=263


ZipFileMember>>#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.

Reply | Threaded
Open this post in threaded view
|

Re: Issue 263 in glassdb: ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error

glassdb

Comment #1 on issue 263 by [hidden email]:  
ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error
http://code.google.com/p/glassdb/issues/detail?id=263

The same holds for
ZipFileMember>>#rewindData

Reply | Threaded
Open this post in threaded view
|

Re: Issue 263 in glassdb: ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error

glassdb
Updates:
        Labels: -Milestone-1.0-beta.8 Version-1.0-beta.8

Comment #2 on issue 263 by [hidden email]:  
ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error
http://code.google.com/p/glassdb/issues/detail?id=263

(sorry, not milestoning)

Reply | Threaded
Open this post in threaded view
|

Re: Issue 263 in glassdb: ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error

glassdb

Comment #3 on issue 263 by [hidden email]:  
ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error
http://code.google.com/p/glassdb/issues/detail?id=263

Sorry, this issue is invalid, a wrong stream is somehow passed. But this  
makes a new issue.

Reply | Threaded
Open this post in threaded view
|

Re: Issue 263 in glassdb: ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error

glassdb
Updates:
        Status: Invalid

Comment #4 on issue 263 by [hidden email]:  
ZipFileMember>>#readLocalDirecotryFileHeaderFrom: has an off-by-one error
http://code.google.com/p/glassdb/issues/detail?id=263

(No comment was entered for this change.)