Skip to content

Increase allocated memory for timestamp index#807

Open
ShangzhiXu wants to merge 1 commit intoCOVESA:masterfrom
ShangzhiXu:master
Open

Increase allocated memory for timestamp index#807
ShangzhiXu wants to merge 1 commit intoCOVESA:masterfrom
ShangzhiXu:master

Conversation

@ShangzhiXu
Copy link
Copy Markdown
Contributor

Further fix #792

@minminlittleshrimp
Copy link
Copy Markdown
Collaborator

minminlittleshrimp commented Feb 24, 2026

Hi @ShangzhiXu
v3. has been released and we now back to normal maintaining phase, is this patch checked/validated your side? how this fix the issue, can you explain a bit further why 1->2 can fix?

@ShangzhiXu
Copy link
Copy Markdown
Contributor Author

cheers~ let me double check~

@ShangzhiXu
Copy link
Copy Markdown
Contributor Author

ShangzhiXu commented Mar 2, 2026

Hi there, sorry for the late reply, I've double checked and this bug is still reproducable on the current version, and the patch works on my side.

It is actually that a off-by-one occurs due to some logic error,

    message_count = (uint32_t) (1 + end - begin); // lets assume message_count = a

    timestamp_index = (TimestampIndex *) malloc(sizeof(TimestampIndex) * (message_count + 1)); // alloc: a + 1 
    ...
    timestamp_index[message_count + 1].num = timestamp_index[0].num; // visit timestamp_index[a + 1]

Here we write timestamp_index[a + 1], but the array has only a + 1 elements, so the valid indices are [0 .. a].
This fix locates message_count + 2 elements to make the valid index range [0 .. a + 1]

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.

[Bug] Protential heap-buffer-overflow crash in dlt-sortbytimestamp.c

2 participants