diff mbox

linux-generic: tm: reduce byte range to prevent array overflow

Message ID 1459024069-14700-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 4eafc08fa4e72f281f6fa4a23a8844a69432bffc
Headers show

Commit Message

Bill Fischofer March 26, 2016, 8:27 p.m. UTC
Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2120 by reducing
the random array guard by one to ensure that at least two bytes of random
data remain before accessing them.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/odp_traffic_mngr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Balasubramanian Manoharan March 28, 2016, 7:58 a.m. UTC | #1
Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org>


Regards,
Bala

On 27 March 2016 at 01:57, Bill Fischofer <bill.fischofer@linaro.org> wrote:

> Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2120 by reducing

> the random array guard by one to ensure that at least two bytes of random

> data remain before accessing them.

>

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

> ---

>  platform/linux-generic/odp_traffic_mngr.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

>

> diff --git a/platform/linux-generic/odp_traffic_mngr.c

> b/platform/linux-generic/odp_traffic_mngr.c

> index 99dc020..08e83c1 100644

> --- a/platform/linux-generic/odp_traffic_mngr.c

> +++ b/platform/linux-generic/odp_traffic_mngr.c

> @@ -154,7 +154,7 @@ static uint16_t tm_random16(tm_random_data_t

> *tm_random_data)

>         uint32_t buf_idx;

>         uint16_t rand8a, rand8b;

>

> -       if (256 <= tm_random_data->next_random_byte)

> +       if (255 <= tm_random_data->next_random_byte)

>                 tm_init_random_data(tm_random_data);

>

>         /* Collect 2 random bytes and return them.  Endianness does NOT

> matter

> --

> 2.5.0

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
Maxim Uvarov March 28, 2016, 9:29 a.m. UTC | #2
Merged,
Maxim.

On 03/28/16 10:58, Bala Manoharan wrote:
> Reviewed-by: Balasubramanian Manoharan <bala.manoharan@linaro.org 
> <mailto:bala.manoharan@linaro.org>>
>
> Regards,
> Bala
>
> On 27 March 2016 at 01:57, Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>> wrote:
>
>     Resolve bug https://bugs.linaro.org/show_bug.cgi?id=2120 by reducing
>     the random array guard by one to ensure that at least two bytes of
>     random
>     data remain before accessing them.
>
>     Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org
>     <mailto:bill.fischofer@linaro.org>>
>     ---
>      platform/linux-generic/odp_traffic_mngr.c | 2 +-
>      1 file changed, 1 insertion(+), 1 deletion(-)
>
>     diff --git a/platform/linux-generic/odp_traffic_mngr.c
>     b/platform/linux-generic/odp_traffic_mngr.c
>     index 99dc020..08e83c1 100644
>     --- a/platform/linux-generic/odp_traffic_mngr.c
>     +++ b/platform/linux-generic/odp_traffic_mngr.c
>     @@ -154,7 +154,7 @@ static uint16_t tm_random16(tm_random_data_t
>     *tm_random_data)
>             uint32_t buf_idx;
>             uint16_t rand8a, rand8b;
>
>     -       if (256 <= tm_random_data->next_random_byte)
>     +       if (255 <= tm_random_data->next_random_byte)
>                     tm_init_random_data(tm_random_data);
>
>             /* Collect 2 random bytes and return them. Endianness does
>     NOT matter
>     --
>     2.5.0
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/platform/linux-generic/odp_traffic_mngr.c b/platform/linux-generic/odp_traffic_mngr.c
index 99dc020..08e83c1 100644
--- a/platform/linux-generic/odp_traffic_mngr.c
+++ b/platform/linux-generic/odp_traffic_mngr.c
@@ -154,7 +154,7 @@  static uint16_t tm_random16(tm_random_data_t *tm_random_data)
 	uint32_t buf_idx;
 	uint16_t rand8a, rand8b;
 
-	if (256 <= tm_random_data->next_random_byte)
+	if (255 <= tm_random_data->next_random_byte)
 		tm_init_random_data(tm_random_data);
 
        /* Collect 2 random bytes and return them.  Endianness does NOT matter