Skip to content

Coverity: Dereference of potentially null field #420

Description

@philiptaff

Describe the bug
In atcah_mac(), param->sn is only checked for null if MAC_MODE_INCLUDE_SN is set in param->mode. But param->sn is always copied to include_data.sn, which is then passed to atcah_include_data() where the pointer is dereferenced (*param->p_temp++ = param->sn[8];) regardless of MAC_MODE_INCLUDE_SN.

To Reproduce
Steps to reproduce the behavior:

  1. Call atcah_mac() with param->sn = NULL and MAC_MODE_INCLUDE_SN != (param->mode & MAC_MODE_INCLUDE_SN).
  2. In line 482, include_data.sn is set to null.
  3. In line 493, the null check is skipped.
  4. In line 546, atcah_include_data() is called, passing include_data with include_data.sn == NULL
  5. In line 64, the null pointer is dereferenced: *param->p_temp++ = param->sn[8];

Expected behavior
Should param->sn always be checked for null in atcah_mac(), regardless of MAC_MODE_INCLUDE_SN? Or in atcah_include_data() should the use of param->sn be gated by MAC_MODE_INCLUDE_SN?

Additional context
This was found in a Coverity scan.

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