libaacs | branch: master | npzacs <npz...@gmail.com> | Tue Oct 15 13:45:08 2013 
+0300| [0601de8b50f2b2432946805d375db9fd37e049c9] | committer: npzacs

Do not fail if vid is known but config file does not exist

> http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=0601de8b50f2b2432946805d375db9fd37e049c9
---

 src/file/keydbcfg-parser.y |    4 ++++
 src/libaacs/aacs.c         |   35 +++++++++++++++++++++--------------
 2 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/src/file/keydbcfg-parser.y b/src/file/keydbcfg-parser.y
index 8780ed3..2f1f087 100644
--- a/src/file/keydbcfg-parser.y
+++ b/src/file/keydbcfg-parser.y
@@ -483,6 +483,10 @@ config_file *keydbcfg_new_config_file(void)
 /* Function that closes and frees a config file object */
 int keydbcfg_config_file_close(config_file *cfgfile)
 {
+  if (!cfgfile) {
+    return 0;
+  }
+
   /* free pk list */
   while (cfgfile->pkl)
   {
diff --git a/src/libaacs/aacs.c b/src/libaacs/aacs.c
index e03dba2..8dea6d1 100644
--- a/src/libaacs/aacs.c
+++ b/src/libaacs/aacs.c
@@ -372,8 +372,7 @@ fprintf(stderr,"pmsn read 2\n");
     return error_code;
 }
 
-static int _calc_vuk(AACS *aacs, uint8_t *mk, uint8_t *vuk,
-                     pk_list *pkl, cert_list *host_cert_list)
+static int _calc_vuk(AACS *aacs, uint8_t *mk, uint8_t *vuk, config_file *cf)
 {
     int error_code;
 
@@ -389,14 +388,18 @@ static int _calc_vuk(AACS *aacs, uint8_t *mk, uint8_t 
*vuk,
         return AACS_SUCCESS;
     }
 
+    if (!cf) {
+        return AACS_ERROR_NO_CONFIG;
+    }
+
     /* make sure we have media key */
-    error_code = _calc_mk(aacs, mk, pkl);
+    error_code = _calc_mk(aacs, mk, cf->pkl);
     if (error_code != AACS_SUCCESS) {
         return error_code;
     }
 
     /* acquire VID */
-    error_code = _read_vid(aacs, host_cert_list);
+    error_code = _read_vid(aacs, cf->host_cert_list);
     if (error_code != AACS_SUCCESS) {
         return error_code;
     }
@@ -578,16 +581,18 @@ static int _calc_uks(AACS *aacs, config_file *cf)
 
     uint8_t mk[16] = {0}, vuk[16] = {0};
 
-    DEBUG(DBG_AACS, "Searching for keydb config entry...\n");
-    _find_config_entry(aacs, cf->list, mk, vuk);
+    if (cf) {
+        DEBUG(DBG_AACS, "Searching for keydb config entry...\n");
+        _find_config_entry(aacs, cf->list, mk, vuk);
 
-    /* Skip if retrieved from config file */
-    if (aacs->uks) {
-        return AACS_SUCCESS;
+        /* Skip if retrieved from config file */
+        if (aacs->uks) {
+            return AACS_SUCCESS;
+        }
     }
 
     /* Make sure we have VUK */
-    error_code = _calc_vuk(aacs, mk, vuk, cf->pkl, cf->host_cert_list);
+    error_code = _calc_vuk(aacs, mk, vuk, cf);
     if (error_code != AACS_SUCCESS) {
         return error_code;
     }
@@ -851,10 +856,6 @@ AACS *aacs_open2(const char *path, const char 
*configfile_path, int *error_code)
     }
 
     cf = keydbcfg_config_load(configfile_path);
-    if (!cf) {
-        *error_code = AACS_ERROR_NO_CONFIG;
-        return aacs;
-    }
 
     DEBUG(DBG_AACS, "Starting AACS waterfall...\n");
     *error_code = _calc_uks(aacs, cf);
@@ -866,6 +867,12 @@ AACS *aacs_open2(const char *path, const char 
*configfile_path, int *error_code)
     aacs->bec = _get_bus_encryption_capable(path);
 
     if (*error_code == AACS_SUCCESS && aacs->bee && aacs->bec) {
+
+        if (!cf) {
+            *error_code = AACS_ERROR_NO_CONFIG;
+            return aacs;
+        }
+
         *error_code = _read_read_data_key(aacs, cf->host_cert_list);
         if (*error_code != AACS_SUCCESS) {
             DEBUG(DBG_AACS | DBG_CRIT, "Unable to initialize bus encryption 
required by drive and disc\n");

_______________________________________________
libaacs-devel mailing list
libaacs-devel@videolan.org
https://mailman.videolan.org/listinfo/libaacs-devel

Reply via email to