8000 Fixes #476: Accessing freed memory in fastboot.c by henrik-haltian · Pull Request #477 · nxp-imx/mfgtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes #476: Accessing freed memory in fastboot.c #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

henrik-haltian
Copy link

The original code takes a pointer (sparse_header * pfile) to a DataBuffer that is freed in subsequent calls to the request_data() function of the underlying FileBuffer. However, the pointer is still used to determine various aspects of the sparse file later. These may be already changed if the memory is reused, which leads to invalid values and trashed transfers.

Fix is to store required file_hdr_sz, blk_sz, total_blks and total_chunks as separate variables.

The original code takes a pointer (sparse_header * pfile) to a
DataBuffer that is freed in subsequent calls to the request_data()
function of the underlying FileBuffer. However, the pointer is still
used to determine various aspects of the sparse file later. These may
be already changed if the memory is reused, which leads to invalid
values and trashed transfers.

Fix is to store required file_hdr_sz, blk_sz, total_blks and
total_chunks as separate variables.

Signed-off-by: Henrik Hedberg <henrik.hedberg@haltian.com>
blk_sz = pfile->blk_sz;
total_blks = pfile->total_blks;
total_chunks = pfile->total_chunks;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does below change work?

sparse_header header = *(sparse_header *)pb->data();
sparse_header * pfile = &header;

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
0