Red Hat Bugzilla – Bug 504081
kernel: TPM: get_event_name stack corruption [mrg-1.2]
Last modified: 2016-05-22 19:28:26 EDT
+++ This bug was initially created as a clone of Bug #503902 +++
Description of problem:
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.
Note: this is not addressed in 188.8.131.52.
This is fixed in 2.6.31.