bplist: reject object lengths that overflow the parser's bounds checks (#90)

The binary plist parser reads an untrusted element/byte count for data,
string, array and dictionary objects and then feeds it into length
arithmetic (start+length, length*2, count*objectRefSize) before its
range checks. A crafted count near 2^64 makes that arithmetic wrap back
into range, so the checks pass and the parser panics in the subsequent
make()/slice instead of returning an error.

Reject counts larger than the number of bytes preceding the offset table
at the point they are parsed; a valid object can never be that large.
2 files changed
tree: b69b285f4e15870c791e85ceeb5c3b5608e7ca00
  1. .github/
  2. cmd/
  3. internal/
  4. testdata/
  5. .gitignore
  6. .gitlab-ci.yml
  7. bplist.go
  8. bplist_generator.go
  9. bplist_parser.go
  10. bplist_test.go
  11. common_data_for_test.go
  12. decode.go
  13. decode_test.go
  14. doc.go
  15. dump_test.go
  16. encode.go
  17. encode_test.go
  18. example_custom_marshaler_test.go
  19. fuzz.go
  20. go.mod
  21. go.sum
  22. go16_test.go
  23. go17_test.go
  24. invalid_bplist_test.go
  25. invalid_text_test.go
  26. LICENSE
  27. marshal.go
  28. marshal_test.go
  29. must.go
  30. plist.go
  31. plist_types.go
  32. README.md
  33. text_generator.go
  34. text_parser.go
  35. text_tables.go
  36. text_test.go
  37. typeinfo.go
  38. unmarshal.go
  39. unmarshal_test.go
  40. util.go
  41. xml_generator.go
  42. xml_parser.go
  43. xml_test.go
  44. zerocopy.go
  45. zerocopy_appengine.go
README.md

plist - A pure Go property list transcoder coverage report

INSTALL

$ go get howett.net/plist

FEATURES

  • Supports encoding/decoding property lists (Apple XML, Apple Binary, OpenStep and GNUStep) from/to arbitrary Go types

USE

package main
import (
	"howett.net/plist"
	"os"
)
func main() {
	encoder := plist.NewEncoder(os.Stdout)
	encoder.Encode(map[string]string{"hello": "world"})
}