Skip to content

Commit

Permalink
fix: increase robustness in connection / invocation decoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Balte de Wit committed Jul 31, 2020
1 parent 88534e2 commit ef28575
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/encodings/ber/decoder/Invocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ function decodeInvocation(
reader.readSequence(Ber.BERDataTypes.SEQUENCE)
seqOffset = reader.offset + reader.length
while (reader.offset < seqOffset) {
reader.readSequence(Ber.CONTEXT(0))
// const dataTag = dataSeq.peek() // TODO I think readValue gets the tag
args.push(reader.readValue())
const tag = reader.readSequence()
if (tag === Ber.CONTEXT(0)) {
args.push(reader.readValue())
} else {
unknownContext(errors, 'decode invocation arguments', tag, options)
skipNext(reader)
}
}
break
case 0:
Expand Down
11 changes: 8 additions & 3 deletions src/encodings/ber/decoder/Matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,14 @@ function decodeConnections(
reader.readSequence(Ber.BERDataTypes.SEQUENCE)
const endOffset = reader.offset + reader.length
while (reader.offset < endOffset) {
reader.readSequence(Ber.CONTEXT(0))
const connection = appendErrors(decodeConnection(reader, options), connections)
connections.value[connection.target] = connection
const tag = reader.readSequence()
if (tag === Ber.CONTEXT(0)) {
const connection = appendErrors(decodeConnection(reader, options), connections)
connections.value[connection.target] = connection
} else {
// unknownContext(errors, 'decode invocation arguments', tag, options)
skipNext(reader)
}
}
return connections
}
Expand Down

0 comments on commit ef28575

Please sign in to comment.