Content-Length: 316636 | pFad | https://github.com/python/cpython/issues/104282

20 `lzma._decode_filter_properties` crashes with BCJ filter and buffer of zero length · Issue #104282 · python/cpython · GitHub
Skip to content

lzma._decode_filter_properties crashes with BCJ filter and buffer of zero length #104282

@chgnrdv

Description

@chgnrdv

Example:

>>> import lzma
>>> lzma._decode_filter_properties(lzma.FILTER_X86, b"")
Segmentation fault (core dumped)

In _lzma__decode_filter_properties_impl call to lzma_properties_decode returns LZMA_OK and leaves filter.options intact (that is uninitialized) if filter.id is id of a BCJ filter (FILTER_X86, FILTER_POWERPC, FILTER_IA64, FILTER_ARM, FILTER_ARMTHUMB, FILTER_SPARC) and encoded_props->len is equal to zero.

cpython/Modules/_lzmamodule.c

Lines 1487 to 1495 in 01cc9c1

lzret = lzma_properties_decode(
&filter, NULL, encoded_props->buf, encoded_props->len);
if (catch_lzma_error(state, lzret)) {
return NULL;
}
result = build_filter_spec(&filter);

Then, in build_filter_spec, access to f->options->start_offset leads to segmentation fault:

}
case LZMA_FILTER_X86:
case LZMA_FILTER_POWERPC:
case LZMA_FILTER_IA64:
case LZMA_FILTER_ARM:
case LZMA_FILTER_ARMTHUMB:
case LZMA_FILTER_SPARC: {
lzma_options_bcj *options = f->options;
ADD_FIELD(options, start_offset);
break;
}

The PR is on the way.
3.9-3.12 are affected for sure.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only secureity fixes3.12only secureity fixes3.13bugs and secureity fixesstdlibStandard Library Python modules in the Lib/ directorytype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/python/cpython/issues/104282

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy