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

FAQ:修复SDK事件数组越界问题 #97

Open
Alexcheesburger opened this issue Dec 19, 2022 · 0 comments
Open

FAQ:修复SDK事件数组越界问题 #97

Alexcheesburger opened this issue Dec 19, 2022 · 0 comments

Comments

@Alexcheesburger
Copy link

一、简介

SDK中发送事件模块中,存在事件数组访问越界问题;

二、涉及SDK版本

ad140-release_v1.4.0 以及之前的版本
ac104n-release_v1.4.0 以及之前的版本
ad150-release_v1.4.0 以及之前的版本

三、解决办法

1.修改 msg.c 中 post_event 函数
输入图片说明

int post_event(int event)
{
    if (event >= ARRAY_SIZE(event2msg)) {
        return MSG_NOT_EVENT;
    }
    CPU_SR_ALLOC();
    OS_ENTER_CRITICAL();
    event_buf[event / 32] |= BIT(event % 32);
    OS_EXIT_CRITICAL();
    return MSG_NO_ERROR;
}

2.修改 msg.c 中 clear_one_event函数
输入图片说明

static void clear_one_event(u32 event)
{
    if(event >= (8*sizeof(event_buf))){
        return;
    }
    CPU_SR_ALLOC();
    OS_ENTER_CRITICAL();
    event_buf[event / 32] &= ~BIT(event % 32);
    OS_EXIT_CRITICAL();
}
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