`stsafea_query_mask_id()` reads `sub_tag` uninitialised when the transfer fails

未关闭 适合新手
#128 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c

调研方向

问题出在 services/stsafea/stsafea_put_query.c 中的 stsafea_query_mask_id(),它在 stsafea_frame_raw_transfer() 之后检查 sub_tag,而不考虑返回值。先阅读 sub_tag 是如何从响应帧中设置的,然后在比较 sub_tag 之前检查基于 ret 的提前返回。当传输失败时返回其自身的错误码而不是 STSE_SERVICE_INCOMPATIBLE_DEVICE_TYPE,并且 sub_tag 始终被初始化时,即完成。

由索引模型根据 Issue 内容生成。

描述

In v1.1.11, stsafea_query_mask_id() (services/stsafea/stsafea_put_query.c) checks sub_tag after stsafea_frame_raw_transfer() whatever its result:

ret = stsafea_frame_raw_transfer(pSTSE, &CmdFrame, &RspFrame, ...);

if (sub_tag != STSAFEA_SUB_TAG_MASK_ID)
{
    return (STSE_SERVICE_INCOMPATIBLE_DEVICE_TYPE);
}

return ret;

When the transfer fails before the response is read (for example STSE_PLATFORM_BUS_ACK_ERROR after every polling retry), sub_tag is never written, so the function reads an uninitialised variable. stse_init() then usually returns STSE_SERVICE_INCOMPATIBLE_DEVICE_TYPE instead of the bus error, and a device that does not answer looks like a device of another type.

The same happens when the device answers with an error status: the payload elements of the response frame are dropped, and sub_tag is not written either.

Suggested fix: return ret first when it is not STSE_OK, then check sub_tag; or initialise sub_tag to a value other than STSAFEA_SUB_TAG_MASK_ID.

Present in v1.1.11 and in main (5e9e04f).

主要语言
C
星标
15
派生
12
平均合并
9 分钟
30 天内合并 PR
3

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

STMicroelectronics/STSELib 的其他 Issue

查看 STMicroelectronics/STSELib 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。