Skip to content
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

log_index2addr 函数存在隐藏风险,建议优化 #12

Open
i-jaffer opened this issue Dec 8, 2022 · 0 comments
Open

log_index2addr 函数存在隐藏风险,建议优化 #12

i-jaffer opened this issue Dec 8, 2022 · 0 comments

Comments

@i-jaffer
Copy link

i-jaffer commented Dec 8, 2022

ef_log.c 文件内的 log_index2addr 函数使用存在隐藏风险,建议可以优化

当给 log_index2addr 传入的参数index 的值 大于 2倍LOG_AREA_SIZE时,回导致计算出来的flash物理地址错误

建议将返回值计算
return log_start_addr + index + header_total_offset - LOG_AREA_SIZE;
修改为
return (log_start_addr + index + header_total_offse)t % LOG_AREA_SIZE;

尽管此函数仅由ef_log_read调用,且ef_log_read函数内做了EF_ASSERT(index < cur_using_size);判断,目前整体是安全的,但是此函数是不安全的,为防止后续其他函数调用是引入风险,建议修改

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

No branches or pull requests

1 participant