Changes for version 0.025 - 2026-12-03

  • New Span->unpack, unpack_to_array, parse_packed and parse_packed_to_array decode integers and length-prefixed fields using perl's pack notation. Bytes ('a') are returned as Spans, and lengths that run past the end of the data are an error rather than being truncated.
  • New append_pack writes the same formats, taking SecretBuffers, Spans or plain values as arguments
  • append_lenprefixed now returns the buffer, for chaining
  • New Span->bytes_needed: if a parse fails because the span ended early, this is the minimum number of additional bytes required
  • Breaking change for C API users: structs secret_buffer_parse and secret_buffer_parse_rw have a new 'bytes_needed' field, changing their size and layout. C code compiled against an earlier SecretBuffer.h must be recompiled, and code that fills in these structs field-by-field must initialize the new field.
  • C API: new secret_buffer_parse_packed and secret_buffer_append_pack
  • Span->parse_lenprefixed($count) now fails if fewer than $count strings are present, instead of returning the ones it found. An empty span is now a failure for the default count of 1.
  • Methods which take bytes or a pattern (append, assign, splice, memcmp, index, scan, and the Span parse, scan, trim, starts_with and cmp methods) now die when given something that isn't a string: a ref to an array, hash, sub or ref, a glob, or an object that doesn't overload stringification. Previously these were treated as an empty string or as text like "HASH(0x1234)".
  • Patterns may now be a ref to a scalar, like the arguments of append
  • Bug fixes for parsing and testing:
    • Fix memcmp ordering of bytes 0x80..0xFF (now unsigned, like C memcmp) This can affect sort order if memcmp were used as a sort function.
    • Fix codepoint U+0080 not matching regex charsets like [[:cntrl:]]
    • Span->encoding no longer accepts the internal-only encoding number 7
    • Fix Span->len and Span->length setters, which always died with "BUG"
    • Fix stale results when a variable holding a regex is assigned a different regex (the charset was cached on the variable instead of the regex)
  • Bug fixes for ConsoleState:
    • Fix ConsoleState->line_input(1) disabling Ctrl-C (ISIG) on POSIX
    • ConsoleState->new now restores echo if setting line_input fails
  • Fix C / XS bugs:
    • write_async and AsyncResult->wait were completely broken when the background writer thread was required. This had been masked by the pipe buffer size absorbing the entire write, preventing the backgroud thread from needing to run.
    • Fix use-after-free when the scalar given to unmask_to outlives its buffer
    • Fix append, assign, splice, memcmp and others treating a substr() result or tied scalar argument as an empty string
    • Fix various undefined behavior when append, assign, splice, substr, or append_lenprefixed was given an argument from the same buffer as was being written.
    • Fix crash in new()/secret() when an attribute method grows Perl's stack
    • Fix crashes using SecretBuffers, Spans or regex charsets in a new ithread
    • Fix file descriptor leak in append_random on systems without getrandom()
    • Fix memory leak of every ConsoleState object

Documentation

Modules

Prevent accidentally leaking a string of sensitive data
Observe results of a write_async operation
Disable TTY echo within a scope
Parse INI format from a SecretBuffer
Parse PEM format from a SecretBuffer
Inspect or alter arrayref of PEM headers as if it was a hashref
Reference a span of bytes within a SecretBuffer

Provides

in lib/Crypt/SecretBuffer.pm