]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
TPM: get_event_name stack corruption
authorEric Paris <eparis@redhat.com>
Wed, 13 May 2009 16:50:40 +0000 (12:50 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 15 Jun 2009 16:40:00 +0000 (09:40 -0700)
commitf631a5124900fff41a53841c220b05433b847256
tree82abc8edd8f1b6044e3b53e0236422119edd6d46
parent6ff8713a30f8f4dff1174b4ea35a0b44679f49a9
TPM: get_event_name stack corruption

commit fbaa58696cef848de818768783ef185bd3f05158 upstream.

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: Eric Paris <eparis@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/char/tpm/tpm_bios.c