• Eric Paris's avatar
    TPM: get_event_name stack corruption · fbaa5869
    Eric Paris authored
    get_event_name uses sprintf to fill a buffer declared on the stack.  It fills
    the buffer 2 bytes at a time.  What the code doesn't take into account is that
    sprintf(buf, "%02x", data) actually writes 3 bytes.  2 bytes for the data and
    then it nul terminates the string.  Since we declare buf to be 40 characters
    long and then we write 40 bytes of data into buf sprintf is going to write 41
    characters.  The fix is to leave room in buf for the nul terminator.
    Signed-off-by: default avatarEric Paris <eparis@redhat.com>
    Signed-off-by: default avatarJames Morris <jmorris@namei.org>
    fbaa5869
tpm_bios.c 11.5 KB