From c6ae9afd73c183231f39804de184e8c5c09de563 Mon Sep 17 00:00:00 2001 From: Xavier Bachelot Date: Wed, 23 Oct 2013 16:56:08 +0000 Subject: [PATCH] Fix off-by-one errors in registers 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 4985cc99..43751d4d 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; } -- 2.26.0