Skip to content

stsafea_query_mask_id() reads sub_tag uninitialised when the transfer fails #128

Open

Description

@AntonioMR

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions