decode sequences from the stream with the provided history but without a dictionary.
(hist []byte)
| 79 | |
| 80 | // decode sequences from the stream with the provided history but without a dictionary. |
| 81 | func (s *sequenceDecs) decodeSyncSimple(hist []byte) (bool, error) { |
| 82 | if len(s.dict) > 0 { |
| 83 | return false, nil |
| 84 | } |
| 85 | if s.maxSyncLen == 0 && cap(s.out)-len(s.out) < maxCompressedBlockSize { |
| 86 | return false, nil |
| 87 | } |
| 88 | |
| 89 | // FIXME: Using unsafe memory copies leads to rare, random crashes |
| 90 | // with fuzz testing. It is therefore disabled for now. |
| 91 | const useSafe = true |
| 92 | |
| 93 | br := s.br |
| 94 | |
| 95 | maxBlockSize := min(s.windowSize, maxCompressedBlockSize) |
| 96 | |
| 97 | ctx := decodeSyncAsmContext{ |
| 98 | llTable: s.litLengths.fse.dt[:maxTablesize], |
| 99 | mlTable: s.matchLengths.fse.dt[:maxTablesize], |
| 100 | ofTable: s.offsets.fse.dt[:maxTablesize], |
| 101 | llState: uint64(s.litLengths.state.state), |
| 102 | mlState: uint64(s.matchLengths.state.state), |
| 103 | ofState: uint64(s.offsets.state.state), |
| 104 | iteration: s.nSeqs - 1, |
| 105 | litRemain: len(s.literals), |
| 106 | out: s.out, |
| 107 | outPosition: len(s.out), |
| 108 | literals: s.literals, |
| 109 | windowSize: s.windowSize, |
| 110 | history: hist, |
| 111 | } |
| 112 | |
| 113 | s.seqSize = 0 |
| 114 | startSize := len(s.out) |
| 115 | |
| 116 | errCode := decodeSyncAsm(s, br, &ctx, useSafe) |
| 117 | switch errCode { |
| 118 | case noError: |
| 119 | break |
| 120 | |
| 121 | case errorMatchLenOfsMismatch: |
| 122 | return true, fmt.Errorf("zero matchoff and matchlen (%d) > 0", ctx.ml) |
| 123 | |
| 124 | case errorMatchLenTooBig: |
| 125 | return true, fmt.Errorf("match len (%d) bigger than max allowed length", ctx.ml) |
| 126 | |
| 127 | case errorMatchOffTooBig: |
| 128 | return true, fmt.Errorf("match offset (%d) bigger than current history (%d)", |
| 129 | ctx.mo, ctx.outPosition+len(hist)-startSize) |
| 130 | |
| 131 | case errorNotEnoughLiterals: |
| 132 | return true, fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", |
| 133 | ctx.ll, ctx.litRemain+ctx.ll) |
| 134 | |
| 135 | case errorOverread: |
| 136 | return true, io.ErrUnexpectedEOF |
| 137 | |
| 138 | case errorNotEnoughSpace: |
no test coverage detected