mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
libekmfweb: Fix size check of the response party info
The party info contained in the response might be of an arbitrary size. Check for an overflow before allocating the party info buffer for the combined request and response party info data. With a very large response party info size, the combined size might overflow (i.e. wrap around), causing a too small buffer being allocated and the following memcpy's would cause an out of bounds write. Assisted-by: IBM Bob:2.0.0 Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com> Reviewed-by: Finn Callies <fcallies@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
35cc35894b
commit
927f901969
@@ -2220,6 +2220,11 @@ static int _ekmf_import_key(unsigned char *req_sess_key,
|
||||
unsigned char *party_info = NULL;
|
||||
int rc;
|
||||
|
||||
if (resp_party_info_length > SIZE_MAX - req_party_info_length) {
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
party_info_length = req_party_info_length + resp_party_info_length;
|
||||
party_info = malloc(party_info_length);
|
||||
if (party_info == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user