[libbluray-devel] [PATCH] Fix off-by-one errors in registers read/write functions

Xavier Bachelot xavier at bachelot.org
Wed Oct 23 18:56:08 CEST 2013


Reported by Florian Weimer.
https://bugzilla.redhat.com/show_bug.cgi?id=959215
---
 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;
     }
-- 
1.8.3.1






More information about the libbluray-devel mailing list