bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] mes: Prevent out-of-bounds access for stack frame 0


From: Jan Nieuwenhuizen
Subject: Re: [PATCH] mes: Prevent out-of-bounds access for stack frame 0
Date: Tue, 06 Apr 2021 19:35:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

W. J. van der Laan writes:

Hi,

> * src/lib.c (make_frame): Add a check to prevent reads outside of the
> stack when trying to determine the procedure for stack frame 0.
> ---
>  src/lib.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> Avoids a segmentation fault or a random value which mucks up things
> later while printing a traceback.

Nice, catch and fix; thanks.  Pushed to wip-riscv for now.

> diff --git a/src/lib.c b/src/lib.c
> index 
> 424a1cccc377f67e55651bfc47f99100225b5e1f..35bdd0c45d85b7e60d2441beaa993cf21608fe3f
>  100644
> --- a/src/lib.c
> +++ b/src/lib.c
> @@ -320,8 +320,12 @@ SCM
>  make_frame (SCM stack, long index)
>  {
>    SCM frame_type = make_frame_type ();
> -  long array_index = (STACK_SIZE - (index * FRAME_SIZE));
> -  SCM procedure = g_stack_array[array_index + FRAME_PROCEDURE];
> +  SCM procedure = 0;
> +  if (index != 0)
> +    {
> +      long array_index = (STACK_SIZE - (index * FRAME_SIZE));
> +      procedure = g_stack_array[array_index + FRAME_PROCEDURE];
> +    }
>    if (!procedure)
>      procedure = cell_f;
>    SCM values = cell_nil;

This is probably (hopefully!) one of the few patches that will apply to
current master, but not to wip-m2 that I'm in the process of finishing
and merging.  Luckily it won't be much work to "port" it to wip-m2.
Let's decide later which feature branch to merge first.

Janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]