<div dir="ltr">Package: aptitude<br>Version: 0.8.13-7<br>Tags: patch<br><br>In src/pkg_columnizer.cc, function pkg_item::pkg_columnizer::setup_columns(),<br>there is a guaranteed null pointer dereference when the default column<br>format string cannot be parsed.<br><br>The relevant code:<br><br>    columns = parse_columns(cfg, ...);<br>    ...<br>    if(!columns)<br>    {<br>        ...<br>        columns = parse_columns(cfg, ...);<br>        if(!columns)<br>        {<br>            _error->Warning(_("Internal error: Default column string is unparsable"));<br>            const cw::config::column_definition col(...);<br>            columns->push_back(col);   // <-- dereference of nullptr<br>        }<br>    }<br><br>parse_columns() from cwidget returns NULL on parse failure. When the second<br>call also fails, columns is nullptr, but the code unconditionally dereferences<br>it. This is undefined behavior (CWE-476).<br><br>Suggested fix:<br><br>    if(!columns)<br>    {<br>        _error->Warning(_("Internal error: Default column string is unparsable"));<br>        columns = new cw::config::column_definition_list;<br>        const cw::config::column_definition col(...);<br>        columns->push_back(col);<br>    }<br><br>or return early to avoid the dereference.<br><br>This is an old upstream bug originally tracked at<br><a href="https://bugs.debian.org/424659">https://bugs.debian.org/424659</a> and similar.<div><br></div><div>--</div><div>Alex Newrow</div></div>