diff options
author | Eric Paris <eparis@redhat.com> | 2009-05-13 12:50:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-06-11 20:01:08 -0700 |
commit | 01683de16233af7676146083f644c823ac5f246d (patch) | |
tree | 20e0164c2f6d90d0565aa8094b4520c9493368b2 /drivers/char | |
parent | 218cadbd4ce2a81d417b6f7b5eb5d5460f221fec (diff) | |
download | lwn-01683de16233af7676146083f644c823ac5f246d.tar.gz lwn-01683de16233af7676146083f644c823ac5f246d.zip |
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>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/tpm/tpm_bios.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c index 68f052b42ed7..2db432df312f 100644 --- a/drivers/char/tpm/tpm_bios.c +++ b/drivers/char/tpm/tpm_bios.c @@ -214,7 +214,8 @@ static int get_event_name(char *dest, struct tcpa_event *event, unsigned char * event_entry) { const char *name = ""; - char data[40] = ""; + /* 41 so there is room for 40 data and 1 nul */ + char data[41] = ""; int i, n_len = 0, d_len = 0; struct tcpa_pc_event *pc_event; |