All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] lib/igt_vec: assertion fortification
Date: Fri, 7 Feb 2020 15:07:19 +0200	[thread overview]
Message-ID: <20200207130719.GW13686@intel.com> (raw)
In-Reply-To: <20200207032725.10731-1-zbigniew.kempczynski@intel.com>

On Fri, Feb 07, 2020 at 04:27:25AM +0100, Zbigniew Kempczyński wrote:
> Ensure no one will pass negative index on igt_vec because it could
> lead to memory corruptions and weird program behavior.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

> ---
>  lib/igt_vec.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_vec.c b/lib/igt_vec.c
> index 591e56fa..c6ba164b 100644
> --- a/lib/igt_vec.c
> +++ b/lib/igt_vec.c
> @@ -41,7 +41,7 @@ void igt_vec_fini(struct igt_vec *vec)
>  
>  void *igt_vec_elem(const struct igt_vec *vec, int idx)
>  {
> -	igt_assert(idx < vec->len);
> +	igt_assert(idx >= 0 && idx < vec->len);
>  
>  	return vec->elems + idx * vec->elem_size;
>  }
> @@ -79,7 +79,7 @@ int igt_vec_index(const struct igt_vec *vec, void *elem)
>  
>  void igt_vec_remove(struct igt_vec *vec, int idx)
>  {
> -	igt_assert(idx < vec->len);
> +	igt_assert(idx >= 0 && idx < vec->len);
>  
>  	memmove(igt_vec_elem(vec, idx),
>  		igt_vec_elem(vec, idx + 1),
> -- 
> 2.23.0

-- 
Ville Syrjälä
Intel
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-02-07 13:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07  3:27 [igt-dev] [PATCH i-g-t] lib/igt_vec: assertion fortification Zbigniew Kempczyński
2020-02-07  3:52 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2020-02-07  3:57 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
2020-02-07 13:07 ` Ville Syrjälä [this message]
2020-02-10  6:09 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2020-02-10  6:50   ` Zbigniew Kempczyński
2020-02-10  7:33     ` Vudum, Lakshminarayana
2020-02-10  7:08 ` Patchwork
2020-02-10  7:23 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200207130719.GW13686@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.