Skip to content
  1. Jan 27, 2025
  2. Jan 05, 2025
  3. Dec 27, 2024
  4. Dec 26, 2024
  5. Dec 25, 2024
  6. Oct 24, 2023
    • Tom Sellers's avatar
      text: address out-of-bounds panic in parseGNUStepValue (#79) · 5afcd134
      Tom Sellers authored
      This PR addresses a `index out of range` panic in `parseGNUStepValue`.
      This panic was identified as part of internal fuzzer based testing of
      our code.
      
      Reproducer
      ```go
      package main
      
      import (
      	"bytes"
      
      	"howett.net/plist"
      )
      
      func main() {
      	data := []byte(`(plist versionGetValue<*B"">`)
      
      	dec := plist.NewDecoder(bytes.NewReader(data))
      	res := make(map[string]interface{})
      
      	_ = dec.Decode(res)
      }
      ```
      
      Results
      
      ```shell
      go run ./main.go
      
      panic: runtime error: index out of range [0] with length 0 [recovered]
      	panic: runtime error: index out of range [0] with length 0 [recovered]
      	panic: runtime error: index out of range [0] with length 0
      
      goroutine 1 [running]:
      howett.net/plist.(*Decoder).Decode.func1()
      	/Users/me/git/go-plist/decode.go:30 +0xac
      panic({0x1023deaa0?, 0x14000116018?})
      	/usr/local/go/src/runtime/panic.go:914 +0x218
      howett.net/plist.(*textPlistParser).parseDocument.func1()
      	/Users/me/git/go-plist/text_parser.go:74 +0xe0
      panic({0x1023deaa0?, 0x14000116018?})
      	/usr/local/go/src/runtime/panic.go:914 +0x218
      howett.net/plist.(*textPlistParser).parseGNUStepValue(0x1400010aea0)
      	/Users/me/git/go-plist/text_parser.go:460 +0x4e0
      howett.net/plist.(*textPlistParser).parsePlistValue(0x1400010aea0)
      	/Users/me/git/go-plist/text_parser.go:554 +0x17c
      howett.net/plist.(*textPlistParser).parseArray(0x1400010aea0)
      	/Users/me/git/go-plist/text_parser.go:399 +0xd4
      howett.net/plist.(*textPlistParser).parsePlistValue(0x1400010aea0)
      	/Users/me/git/go-plist/text_parser.go:567 +0x190
      howett.net/plist.(*textPlistParser).parseDocument(0x1400010aea0)
      	/Users/me/git/go-plist/text_parser.go:91 +0xa4
      howett.net/plist.(*Decoder).Decode(0x14000140000, {0x1023d21e0, 0x140001101b0})
      	/Users/me/git/go-plist/decode.go:58 +0x210
      main.main()
      	/Users/me/git/go-plist/cmd/crasher/main.go:15 +0xfc
      exit status 2
      ```
      
      I built a quick Fuzzer for `Decode` with a good test corpus in order to
      identify related bugs but nothing shook out in roughly an hour. 
      v1.0.1
      5afcd134
  7. May 01, 2023
    • Семён Марьясин's avatar
      bplist: teach the parser about unusual OffsetIntSize values (#78) · e03e84eb
      Семён Марьясин authored
      This is only a partial fix which works for the value of 3 and for any
      value < 8, but won't help in other cases. Supporting values < 16 should
      also be possible, but I didn't bother with it. Also this doesn't touch
      `bplist_generator` and hence won't make use of non-standard values for
      generating plists (while those values could probably give a benefit of
      slightly reduced plist size).
      
      We confirmed that this is supported by the CoreFoundation bplist parser.
      
      Closes #77
      e03e84eb
  8. Nov 02, 2022
  9. Nov 27, 2021
  10. Dec 03, 2020
  11. Oct 26, 2020
    • Dustin L. Howett's avatar
      unmarshal: replace manual array element copy with reflect.Copy · 117a925f
      Dustin L. Howett authored
      This commit also adds a benchmark for array unmarshaling. The difference
      is staggering.
      
      name                   old time/op    new time/op    delta
      LargeArrayUnmarshal-4    23.4µs ± 2%     0.4µs ± 2%  -98.49%  (p=0.000 n=9+9)
      
      name                   old alloc/op   new alloc/op   delta
      LargeArrayUnmarshal-4     96.0B ± 0%    128.0B ± 0%  +33.33%  (p=0.000 n=10+10)
      
      name                   old allocs/op  new allocs/op  delta
      LargeArrayUnmarshal-4      3.00 ± 0%      4.00 ± 0%  +33.33%  (p=0.000 n=10+10)
      117a925f
  12. Oct 25, 2020
  13. Apr 19, 2020
  14. Feb 25, 2020
  15. Nov 24, 2018
  16. Jul 29, 2018
  17. Jun 13, 2018
  18. Jun 09, 2018
  19. Jun 06, 2018
  20. Apr 27, 2018
  21. Feb 17, 2018
    • Dustin L. Howett's avatar
      xml: rewrite the xml generator to avoid xml.Encoder · 84d08b7b
      Dustin L. Howett authored
      This commit intoduces a mostly hand-rolled XML encoder inspired by
      xml.Encoder. Since plist is a simple format that doesn't require
      attributes, only has one data type with encodeable input and is
      otherwise constrained, we don't need the full power of encoding/xml.
      
      The encoder's speed, memory requirements and number of allocations are
      all improved.
      
      In addition, we can now emit self-closing tags for empty elements
      (<key></key> -> <key/>).
      
      Fixes https://github.com/DHowett/go-plist/issues/34.
      
      name                    old time/op    new time/op    delta
      XMLEncode-4               25.9µs ± 3%    14.9µs ± 1%   -42.66%
      BigXMLGenerate-4          47.3ms ± 1%    23.7ms ± 1%   -49.91%
      BigPrettyXMLGenerate-4    55.0ms ± 1%    30.0ms ± 1%   -45.42%
      XMLGenerate-4             16.0µs ± 1%     5.8µs ± 1%   -63.81%
      
      name                    old alloc/op   new alloc/op   delta
      XMLEncode-4               8.71kB ± 0%    6.42kB ± 0%   -26.26%
      BigXMLGenerate-4          2.62MB ± 0%    1.60MB ± 0%   -39.02%
      BigPrettyXMLGenerate-4    2.62MB ± 0%    1.60MB ± 0%   -39.02%
      XMLGenerate-4             5.83kB ± 0%    4.50kB ± 0%   -22.77%
      
      name                    old allocs/op  new allocs/op  delta
      XMLEncode-4                 88.0 ± 0%      63.0 ± 0%   -28.41%
      BigXMLGenerate-4           86.7k ± 0%     72.6k ± 0%   -16.24%
      BigPrettyXMLGenerate-4     86.7k ± 0%     72.6k ± 0%   -16.24%
      XMLGenerate-4               54.0 ± 0%      31.0 ± 0%   -42.59%
      84d08b7b
  22. Feb 11, 2018
  23. Feb 08, 2018
  24. Nov 05, 2017
Loading