[libdvdnav-devel] [Git][videolan/libdvdnav][master] 2 commits: Add checks to ensure state->pgc validity

Jean-Baptiste Kempf gitlab at videolan.org
Sun Jan 14 10:49:14 CET 2018


Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdnav


Commits:
08820eb4 by Pierre Lamot at 2018-01-14T10:49:08+01:00
Add checks to ensure state->pgc validity

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

- - - - -
39b976dc by Pierre Lamot at 2018-01-14T10:49:08+01:00
Update comments

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

- - - - -


5 changed files:

- src/dvdnav.c
- src/highlight.c
- src/navigation.c
- src/vm/getset.c
- src/vm/play.c


Changes:

=====================================
src/dvdnav.c
=====================================
--- a/src/dvdnav.c
+++ b/src/dvdnav.c
@@ -485,6 +485,9 @@ int64_t dvdnav_get_current_time(dvdnav_t *this) {
   int64_t tm=0;
   dvd_state_t *state = &this->vm->state;
 
+  if(! state->pgc)
+    return 0;
+
   for(i=0; i<state->cellN-1; i++) {
     if(!
         (state->pgc->cell_playback[i].block_type == BLOCK_TYPE_ANGLE_BLOCK &&
@@ -517,6 +520,12 @@ dvdnav_status_t dvdnav_get_next_cache_block(dvdnav_t *this, uint8_t **buf,
     this->started = 1;
   }
 
+  if (!this->vm->state.pgc) {
+      printerr("No current PGC.");
+      pthread_mutex_unlock(&this->vm_lock);
+      return DVDNAV_STATUS_ERR;
+  }
+
   state = &(this->vm->state);
   (*event) = DVDNAV_NOP;
   (*len) = 0;


=====================================
src/highlight.c
=====================================
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -343,6 +343,12 @@ dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) {
   }
   pthread_mutex_lock(&this->vm_lock);
 
+  if(!this->vm->state.pgc) {
+    printerr("No current PGC.");
+    pthread_mutex_unlock(&this->vm_lock);
+    return DVDNAV_STATUS_ERR;
+  }
+
   button = this->vm->state.HL_BTNN_REG >> 10;
 
   if((button <= 0) || (button > pci->hli.hl_gi.btn_ns)) {
@@ -394,6 +400,13 @@ dvdnav_status_t dvdnav_button_activate(dvdnav_t *this, pci_t *pci) {
 dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd)
 {
   pthread_mutex_lock(&this->vm_lock);
+
+  if(!this->vm->state.pgc) {
+    printerr("No current PGC.");
+    pthread_mutex_unlock(&this->vm_lock);
+    return DVDNAV_STATUS_ERR;
+  }
+
   /* make the VM execute the appropriate code and probably
    * schedule a jump */
 #ifdef BUTTON_TESTING


=====================================
src/navigation.c
=====================================
--- a/src/navigation.c
+++ b/src/navigation.c
@@ -269,6 +269,12 @@ dvdnav_status_t dvdnav_go_up(dvdnav_t *this) {
   /* A nice easy function... delegate to the VM */
   int retval;
   pthread_mutex_lock(&this->vm_lock);
+  if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
+    pthread_mutex_unlock(&this->vm_lock);
+    return DVDNAV_STATUS_ERR;
+  }
+
   retval = vm_jump_up(this->vm);
   pthread_mutex_unlock(&this->vm_lock);
 


=====================================
src/vm/getset.c
=====================================
--- a/src/vm/getset.c
+++ b/src/vm/getset.c
@@ -172,6 +172,9 @@ int set_PGN(vm_t *vm) {
   int new_pgN = 0;
   int dummy, part = 0;
 
+  if ((vm->state).pgc == NULL)
+    return 0;
+
   while(new_pgN < (vm->state).pgc->nr_of_programs
         && (vm->state).cellN >= (vm->state).pgc->program_map[new_pgN])
     new_pgN++;
@@ -280,6 +283,10 @@ int get_PGCN(vm_t *vm) {
   pgcit_t *pgcit;
   int pgcN = 1;
 
+  if ((vm->state).pgc == NULL) {
+    return 0; /* error */
+  }
+
   pgcit = get_PGCIT(vm);
 
   if (pgcit) {


=====================================
src/vm/play.c
=====================================
--- a/src/vm/play.c
+++ b/src/vm/play.c
@@ -216,8 +216,8 @@ link_t play_Cell(vm_t *vm) {
       }
 #endif
       break;
-    case 2: /*  ?? */
-    case 3: /*  ?? */
+    case 2: /*  reserved */
+    case 3: /*  reserved */
     default:
       fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
               (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,
@@ -304,8 +304,8 @@ link_t play_Cell_post(vm_t *vm) {
         (vm->state).cellN++;
       }
       break;
-    case 2: /*  ?? */
-    case 3: /*  ?? */
+    case 2: /*  reserved */
+    case 3: /*  reserved */
     default:
       fprintf(MSG_OUT, "libdvdnav: Invalid? Cell block_mode (%d), block_type (%d)\n",
               (vm->state).pgc->cell_playback[(vm->state).cellN - 1].block_mode,



View it on GitLab: https://code.videolan.org/videolan/libdvdnav/compare/0f6e70895cef951d4aa1589f473f80c420998804...39b976dc3387cf50361dd4fa94bb95c17b95091f

---
View it on GitLab: https://code.videolan.org/videolan/libdvdnav/compare/0f6e70895cef951d4aa1589f473f80c420998804...39b976dc3387cf50361dd4fa94bb95c17b95091f
You're receiving this email because of your account on code.videolan.org.


More information about the libdvdnav-devel mailing list