Commit da8a5fb8 authored by npzacs's avatar npzacs
Browse files

check memory allocation result

parent 9c73ea81
......@@ -64,11 +64,11 @@ CONTENT_CERT *cc_parse(const void *data, size_t len)
/* return useful data */
CONTENT_CERT *c = calloc(1, sizeof(CONTENT_CERT));
c->bus_encryption_enabled_flag = p[1] >> 7;
memcpy(c->cc_id, p + 14, 6);
memcpy(c->bdj_root_cert_hash, p + 46, 20);
if (c) {
c->bus_encryption_enabled_flag = p[1] >> 7;
memcpy(c->cc_id, p + 14, 6);
memcpy(c->bdj_root_cert_hash, p + 46, 20);
}
return c;
}
......
......@@ -255,9 +255,15 @@ static uint8_t *_mmc_read_mkb(MMC *mmc, uint8_t agid, int address, int *size)
if (_mmc_report_disc_structure(mmc, agid, 0x83, layer, address, buf, sizeof(buf))) {
unsigned pack, num_packs = buf[3];
int32_t len = MKINT_BE16(buf) - 2;
mkb = malloc(32768 * num_packs);
BD_DEBUG(DBG_MMC, "got mkb: pack 0/%d %d bytes\n", num_packs, len);
mkb = malloc(32768 * num_packs);
if (!mkb) {
BD_DEBUG(DBG_MMC | DBG_CRIT, "out of memory\n");
return NULL;
}
memcpy(mkb, buf + 4, len);
*size += len;
......@@ -347,6 +353,9 @@ MMC *mmc_open(const char *path)
}
mmc = calloc(1, sizeof(MMC));
if (!mmc) {
return NULL;
}
crypto_create_nonce(mmc->host_nonce, sizeof(mmc->host_nonce));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment