cryptfs: Avoid dereferencing null pointer

We already know that "intermediate_key" is non-NULL here.  We
care if the result of the allocation, "*intermediate_key", is
non-NULL prior to our memcpy.

Change-Id: I83e22dfadabb870d527b93b31470bf47e22201bb
This commit is contained in:
Greg Kaiser 2016-04-20 10:50:15 -07:00
parent 9247987e84
commit e8167afe55

View file

@ -1452,7 +1452,7 @@ static int decrypt_master_key_aux(const char *passwd, unsigned char *salt,
/* Copy intermediate key if needed by params */
if (intermediate_key && intermediate_key_size) {
*intermediate_key = (unsigned char*) malloc(KEY_LEN_BYTES);
if (intermediate_key) {
if (*intermediate_key) {
memcpy(*intermediate_key, ikey, KEY_LEN_BYTES);
*intermediate_key_size = KEY_LEN_BYTES;
}