Skip to content

Commit

Permalink
Protect against short map section
Browse files Browse the repository at this point in the history
  • Loading branch information
icza committed Oct 18, 2024
1 parent 9103d58 commit c52cea3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/screp/screp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

const (
appName = "screp"
appVersion = "v1.12.2"
appVersion = "v1.12.3"
appAuthor = "Andras Belicza"
appHome = "https://github.com/icza/screp"
)
Expand Down
6 changes: 5 additions & 1 deletion repparser/repparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import (

const (
// Version is a Semver2 compatible version of the parser.
Version = "v1.12.2"
Version = "v1.12.3"
)

var (
Expand Down Expand Up @@ -791,6 +791,10 @@ func parseMapData(data []byte, r *rep.Replay, cfg Config) error {
// Map data section is a sequence of sub-sections:
for sr, size := (sliceReader{b: data}), uint32(len(data)); sr.pos < size; {
id := sr.getString(4)
// Seen examples where a "final" UPUS section following UPRP section had only 1 byte hereon, so check:
if sr.pos+4 >= size {
break
}
ssSize := sr.getUint32() // sub-section size (remaining)
ssEndPos := sr.pos + ssSize // sub-section end position

Expand Down

0 comments on commit c52cea3

Please sign in to comment.