提交 abb57204 编写于 作者: J Jinliang Li 提交者: skylarCai

osal_aos: fix whitescan bugs in rhino/common.c

[Detail]
fix whitescan bugs in rhino/common.c
CWE676: The called function is unsafe for security related code
"rand" should not be used for security-related applications, because
linear congruential algorithms are too easy to break.

[Verified Cases]
Build Pass: <py_engine_demo>
Test Pass:  <py_engine_demo>
Signed-off-by: NJinliang Li <ljl150821@alibaba-inc.com>
上级 883ee734
......@@ -66,21 +66,21 @@ void aos_srand(uint32_t seed)
seed_val = SEED_MAGIC;
}
seed_val += seed;
srand(seed_val);
srandom(seed_val);
seed_val = rand();
seed_val = (uint32_t)random();
ret = aos_kv_set(g_seed_key, &seed_val, sizeof(seed_val), 1);
if (ret) {
printf("aos_kv_set error, return :%d\r\n", ret);
}
#else
srand(seed);
srandom(seed);
#endif
}
int32_t aos_rand(void)
{
return rand();
return (int32_t)random();
}
const char *aos_comp_version_get(const char *comp_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册