Fixed endless loop in _record Fixed a few related procedures to take care of error-result in _record Added a new debug log in case no UVS got detected Fixed debug log output that includes discid in _find_config_entry Added support for empty unit_key_ro.inf file that needs special care Reason for changes: https://github.com/OpenELEC/OpenELEC.tv/pull/4378 --- src/libaacs/aacs.c | 13 +++++++++---- src/libaacs/mkb.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/libaacs/aacs.c b/src/libaacs/aacs.c index ae85612..af4ae82 100644 --- a/src/libaacs/aacs.c +++ b/src/libaacs/aacs.c @@ -286,6 +286,7 @@ static int _calc_pk_mk(MKB *mkb, dk_list *dkl, uint8_t *mk) num_uvs = len / 5; if (num_uvs < 1) { + BD_DEBUG(DBG_AACS, "No UVS detected - corrupted disc\n"); return AACS_ERROR_CORRUPTED_DISC; } @@ -710,6 +711,7 @@ static void _find_config_entry(AACS *aacs, title_entry_list *ce, uint8_t *mk, uint8_t *vuk) { char str[48]; + char str2[48]; aacs->uks = NULL; aacs->num_uks = 0; @@ -731,7 +733,7 @@ static void _find_config_entry(AACS *aacs, title_entry_list *ce, hexstring_to_hex_array(mk, 16, ce->entry.mek); BD_DEBUG(DBG_AACS, "Found media key for %s: %s\n", - ce->entry.discid, str_print_hex(str, mk, 16)); + str_print_hex(str2, ce->entry.discid, 20), str_print_hex(str, mk, 16)); } if (ce->entry.vid) { @@ -739,14 +741,14 @@ static void _find_config_entry(AACS *aacs, title_entry_list *ce, ce->entry.vid); BD_DEBUG(DBG_AACS, "Found volume id for %s: %s\n", - ce->entry.discid, str_print_hex(str, aacs->vid, 16)); + str_print_hex(str2, ce->entry.discid, 20), str_print_hex(str, aacs->vid, 16)); } if (ce->entry.vuk) { hexstring_to_hex_array(vuk, 16, ce->entry.vuk); BD_DEBUG(DBG_AACS, "Found volume unique key for %s: %s\n", - ce->entry.discid, str_print_hex(str, vuk, 16)); + str_print_hex(str2, ce->entry.discid, 20), str_print_hex(str, vuk, 16)); } if (ce->entry.uk) { @@ -1064,8 +1066,11 @@ int aacs_open_device(AACS *aacs, const char *path, const char *configfile_path) error_code = _calc_title_hash(aacs); if (error_code != AACS_SUCCESS) { return error_code; + } else if (!memcmp(aacs->disc_id, "\xEC\x6A\xFE\x5D\xF8\xA1\x32\x50\x68\xB9\x53\x13\xF8\x2B\xD7\x2C\x09\xD4\xF9\x63", 20)) { + /* in case the unit_key_ro.inf contains only NULL byte values it's SHA1 hash is 'ec6afe5df8a1325068b95313f82bd72c09d4f963' - there are a few unencrypted discs available that need a special workaround */ + BD_DEBUG(DBG_AACS, "Detected 0-Byte AACS file - no AACS processing necessary\n"); + return AACS_SUCCESS; } - cf = keydbcfg_config_load(configfile_path); BD_DEBUG(DBG_AACS, "Starting AACS waterfall...\n"); diff --git a/src/libaacs/mkb.c b/src/libaacs/mkb.c index 275b269..9de4beb 100644 --- a/src/libaacs/mkb.c +++ b/src/libaacs/mkb.c @@ -52,6 +52,12 @@ static const uint8_t *_record(MKB *mkb, uint8_t type, size_t *rec_len) return mkb->buf + pos; } + if (len == 0) { + BD_DEBUG(DBG_MKB, "Couldn't retrieved MKB record 0x%02x - len=0 (%p)\n", type, + (void*)(mkb->buf + pos)); + break; + } + pos += len; } @@ -108,6 +114,10 @@ uint8_t mkb_type(MKB *mkb) { const uint8_t *rec = _record(mkb, 0x10, NULL); + if (!rec) { + return 0; + } + return MKINT_BE32(rec + 4); } @@ -115,6 +125,9 @@ uint32_t mkb_version(MKB *mkb) { const uint8_t *rec = _record(mkb, 0x10, NULL); + if (!rec) { + return 0; + } return MKINT_BE32(rec + 8); } @@ -130,6 +143,9 @@ const uint8_t *mkb_host_revokation_entries(MKB *mkb, size_t *len) { const uint8_t *rec = _record(mkb, 0x21, len); + if (!rec) { + return NULL; + } if (rec) { rec += 4; *len -= 4; @@ -142,6 +158,9 @@ const uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len) { const uint8_t *rec = _record(mkb, 0x20, len); + if (!rec) { + return NULL; + } if (rec) { rec += 4; *len -= 4; @@ -153,6 +172,9 @@ const uint8_t *mkb_drive_revokation_entries(MKB *mkb, size_t *len) const uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len) { const uint8_t *rec = _record(mkb, 0x04, len) + 4; + if (!rec) { + return NULL; + } *len -= 4; return rec; @@ -161,6 +183,9 @@ const uint8_t *mkb_subdiff_records(MKB *mkb, size_t *len) const uint8_t *mkb_cvalues(MKB *mkb, size_t *len) { const uint8_t *rec = _record(mkb, 0x05, len) + 4; + if (!rec) { + return NULL; + } *len -= 4; return rec; @@ -174,6 +199,9 @@ const uint8_t *mkb_mk_dv(MKB *mkb) const uint8_t *mkb_signature(MKB *mkb, size_t *len) { const uint8_t *rec = _record(mkb, 0x02, len); + if (!rec) { + return NULL; + } *len -= 4; return rec + 4; -- 2.6.3.windows.1 _______________________________________________ libaacs-devel mailing list libaacs-devel@videolan.org https://mailman.videolan.org/listinfo/libaacs-devel