Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

【优化】读写接口溢出问题 #31

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

Conversation

cproape
Copy link

@cproape cproape commented Apr 22, 2021

No description provided.

@armink
Copy link
Member

armink commented Aug 7, 2021

@Guozhanxin 请安排人确认一下这个问题

@@ -411,7 +411,7 @@ int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t
assert(part);
assert(buf);

if (addr + size > part->len)
if (addr >= part->len || part->len - addr < size)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (addr >= part->len || part->len - addr < size)
if (addr >= part->len || addr + size > part->len)

改成这种方式吧,上面那个感觉逻辑不太直观

Copy link
Contributor

Choose a reason for hiding this comment

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

他的意思是 addr+size 有可能会溢出吧,所以改成了减

Copy link
Member

Choose a reason for hiding this comment

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

有测试的用例吗?

Copy link
Contributor

Choose a reason for hiding this comment

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

其实只有当,fal 管理的地址空间达到 4G 的时候,才会出现这个问题。
021482fd51f8bee487cb0850fe3e4a1

@Guozhanxin
Copy link
Contributor

@cproape 兄弟,你的flash大小是多大的啊,怎么会溢出的呢😂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants