[libbluray-devel] Fix off-by-one errors in registers

Xavier Bachelot git at videolan.org
Thu Oct 24 11:15:52 CEST 2013


libbluray | branch: master | Xavier Bachelot <xavier at bachelot.org> | Wed Oct 23 16:56:08 2013 +0000| [c6ae9afd73c183231f39804de184e8c5c09de563] | committer: npzacs

Fix off-by-one errors in registers

Reported by Florian Weimer.
https://bugzilla.redhat.com/show_bug.cgi?id=959215

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=c6ae9afd73c183231f39804de184e8c5c09de563
---

 src/libbluray/register.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/register.c b/src/libbluray/register.c
index 4985cc9..43751d4 100644
--- a/src/libbluray/register.c
+++ b/src/libbluray/register.c
@@ -339,7 +339,7 @@ void bd_psr_restore_state(BD_REGISTERS *p)
 
 int bd_gpr_write(BD_REGISTERS *p, int reg, uint32_t val)
 {
-    if (reg < 0 || reg > BD_GPR_COUNT) {
+    if (reg < 0 || reg >= BD_GPR_COUNT) {
         BD_DEBUG(DBG_BLURAY, "bd_gpr_write(%d): invalid register\n", reg);
         return -1;
     }
@@ -350,7 +350,7 @@ int bd_gpr_write(BD_REGISTERS *p, int reg, uint32_t val)
 
 uint32_t bd_gpr_read(BD_REGISTERS *p, int reg)
 {
-    if (reg < 0 || reg > BD_GPR_COUNT) {
+    if (reg < 0 || reg >= BD_GPR_COUNT) {
         BD_DEBUG(DBG_BLURAY, "bd_gpr_read(%d): invalid register\n", reg);
         return -1;
     }
@@ -366,7 +366,7 @@ uint32_t bd_psr_read(BD_REGISTERS *p, int reg)
 {
     uint32_t val;
 
-    if (reg < 0 || reg > BD_PSR_COUNT) {
+    if (reg < 0 || reg >= BD_PSR_COUNT) {
         BD_DEBUG(DBG_BLURAY, "bd_psr_read(%d): invalid register\n", reg);
         return -1;
     }
@@ -382,7 +382,7 @@ uint32_t bd_psr_read(BD_REGISTERS *p, int reg)
 
 int bd_psr_setting_write(BD_REGISTERS *p, int reg, uint32_t val)
 {
-    if (reg < 0 || reg > BD_PSR_COUNT) {
+    if (reg < 0 || reg >= BD_PSR_COUNT) {
         BD_DEBUG(DBG_BLURAY, "bd_psr_write(%d, %d): invalid register\n", reg, val);
         return -1;
     }



More information about the libbluray-devel mailing list