Skip to content

Commit

Permalink
Ignore checksums in snappy (Apple does not set them, they will fail)
Browse files Browse the repository at this point in the history
See Issue #8
  • Loading branch information
mish15 committed Apr 27, 2015
1 parent 0342ad8 commit df758a4
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions snappy/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,20 @@ func (r *Reader) Read(p []byte) (int, error) {
switch chunkType {
case chunkTypeCompressedData:
// Section 4.2. Compressed data (chunk type 0x00).
if chunkLen < checksumSize {
r.err = ErrCorrupt
return 0, r.err
}
/*
if chunkLen < checksumSize {
r.err = ErrCorrupt
return 0, r.err
}
*/
buf := r.buf[:chunkLen]
if !r.readFull(buf) {
return 0, r.err
}
checksum := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24
buf = buf[checksumSize:]

/*
checksum := uint32(buf[0]) | uint32(buf[1])<<8 | uint32(buf[2])<<16 | uint32(buf[3])<<24
buf = buf[checksumSize:]
*/
n, err := DecodedLen(buf)
if err != nil {
r.err = err
Expand All @@ -228,10 +231,12 @@ func (r *Reader) Read(p []byte) (int, error) {
r.err = err
return 0, r.err
}
if crc(r.decoded[:n]) != checksum {
r.err = ErrCorrupt
return 0, r.err
}
/*
if crc(r.decoded[:n]) != checksum {
r.err = ErrCorrupt
return 0, r.err
}
*/
r.i, r.j = 0, n
continue

Expand Down

0 comments on commit df758a4

Please sign in to comment.