mirror of
https://github.com/stefanberger/libtpms
synced 2026-01-19 18:56:55 +00:00
tpm12: ubsan: prevent source address NULL passed to memcpy
memcpy() is called with source address NULL, which causes an error with ubsan. Coincidentally data_length is also 0, so nothing bad happens. So we simply intercept the data_length = 0 case. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
60c64ddaaf
commit
8b4944fec2
@ -257,8 +257,10 @@ TPM_RESULT TPM_Sbuffer_Append(TPM_STORE_BUFFER *sbuffer,
|
||||
}
|
||||
/* append the data */
|
||||
if (rc == 0) {
|
||||
memcpy(sbuffer->buffer_current, data, data_length);
|
||||
sbuffer->buffer_current += data_length;
|
||||
if (data_length > 0) { /* libtpms added (ubsan) */
|
||||
memcpy(sbuffer->buffer_current, data, data_length);
|
||||
sbuffer->buffer_current += data_length;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user