Skip to content

fix: filetransferplugin heap corruption on missing packages - #879

Open
louis-e wants to merge 2 commits into
COVESA:masterfrom
louis-e:fix/filetransfer-missing-packages
Open

louis-e wants to merge 2 commits into
COVESA:masterfrom
louis-e:fix/filetransfer-missing-packages

Conversation

@louis-e

@louis-e louis-e commented Nov 5, 2026

Copy link
Copy Markdown

Problem

Opening a trace that contains a file transfer with missing FLDA packages crashes DLT Viewer with a heap corruption (0xC0000374) or an access violation in filetransferplugin.

Root cause

File::setQFileIndexForPackage() calls QList::insert(packageNumber - 1, index). Since 2addbcc the position is only checked against the announced package count, not the current list size. After a gap (for example package 259 followed by 412) the insert position is beyond size(). Release builds don't check this, so the plugin writes past the end of the buffer. Separately, insert() shifts entries, so a duplicate package would scramble the saved file. Rejected packages were also counted as received, so a transfer could show as complete while slots were still missing.

Fix

The index is now a fixed-size QVector<int> with one slot per announced package. Each package is written into its own slot. Packages that are out of range or duplicated are ignored, and only newly filled slots count as received. This also removes a leaked new QList<int>[packages].

Testing

Built on Windows with Qt 6.8.3 and MinGW 13.1. I tested on a ~2 GB trace (12.7 M messages, 304 file transfers, 2 of them with missing packages), which I can't share, using dlt-viewer -t -e "Filetransfer Plugin|export|<dir>" trace.dlt:

  • 2.31.0: crashes after about 19 s with 0xC0000374.
  • With this fix: completes and exports 194 files. Every exported file is byte-identical to the payload rebuilt directly from the FLDA messages, and no zip file is corrupt.

Comment thread plugin/filetransferplugin/file.h Resolved
@Renu-Priya411

Copy link
Copy Markdown
Collaborator

Kindly rebase the code

setQFileIndexForPackage() stored each FLDA package with
QList::insert(packageNumber - 1, index) but only checked the position
against the announced package count. If a package is missing from the
trace (dropped messages, recording started or stopped mid-transfer),
the position is beyond the list size. QList::insert does not check the
range in release builds, so the plugin writes past the end of the list
buffer, corrupts the heap and crashes DLT Viewer shortly after such a
file is opened.

Store the message index per package in a fixed-size table instead:
- one slot per announced package, -1 = not received
- reject package numbers outside 1..packages
- ignore duplicate packages
- count a package only when its slot is filled, so a transfer is
  marked complete only when every package is present

This also removes the QList<int>[packages] array that was never freed.

Regression from 2addbcc, which replaced the (i-1) <= length() check
with (i-1) < packages.
@louis-e
louis-e force-pushed the fix/filetransfer-missing-packages branch from 5422905 to a06c010 Compare November 20, 2026 08:27
@louis-e

louis-e commented Nov 20, 2026

Copy link
Copy Markdown
Author

Thanks, rebased it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants