Re: [PATCH v2] Fix segfault when restoring w_alt.cursor

Sadrul Habib Chowdhury <[email protected]>
Newsgroups gmane.comp.gnu.screen.user
Message-ID <CACdzHCims161w2+EKX6GD+mzM73nsdo9yv1Nq9K173=RZkHReg@mail.gmail.com>
Thanks! Pushed fix in
http://git.savannah.gnu.org/cgit/screen.git/commit/?id=548eebae59f7b91b55587cfe5b580eb02a2d416d

Sadrul

On Fri, Aug 10, 2012 at 3:24 PM, Michael Spang <[email protected]> wrote:

> Screen can be segfaulted with the following steps:
>
>   - Start screen
>   - Enable altscreen with ":altscreen on"
>   - Enable caption with ":caption always"
>   - Run vim
>   - Resize the current terminal to one line high
>   - Resize the current terminal to multiple lines high
>   - Quit vim
>
> This happens because if the canvas height is 0, the alt cursor will be
> adjusted to he - 1 == -1. When we later restore this cursor screen
> crashes. I've reordered the sanity checks for w_saved in case there is
> a similar bug for the saved cursor.
> ---
>
> This fixes the same bug as the previous patch "Forbid creation of
> zero-height canvas".
>
> ChangeLog
>
> v2 - This is a less paranoid version that just fixes the one
> problematic path. It allows screen to render correctly when the only
> available line is taken by the caption.
>
>  src/resize.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/resize.c b/src/resize.c
> index 0e491eb..3c2b90f 100644
> --- a/src/resize.c
> +++ b/src/resize.c
> @@ -966,14 +966,16 @@ int wi, he, hi;
>      p->w_y = he - 1;
>    if (p->w_saved.x > wi)
>      p->w_saved.x = wi;
> -  if (p->w_saved.y < 0)
> -    p->w_saved.y = 0;
>    if (p->w_saved.y >= he)
>      p->w_saved.y = he - 1;
> +  if (p->w_saved.y < 0)
> +    p->w_saved.y = 0;
>    if (p->w_alt.cursor.x > wi)
>      p->w_alt.cursor.x = wi;
>    if (p->w_alt.cursor.y >= he)
>      p->w_alt.cursor.y = he - 1;
> +  if (p->w_alt.cursor.y < 0)
> +    p->w_alt.cursor.y = 0;
>
>    /* reset scrolling region */
>    p->w_top = 0;
> --
> 1.7.7.3
>
>
> _______________________________________________
> screen-users mailing list
> screen-users-mXXj517/[email protected]
> https://lists.gnu.org/mailman/listinfo/screen-users
>

_______________________________________________
screen-users mailing list
screen-users-mXXj517/[email protected]
https://lists.gnu.org/mailman/listinfo/screen-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.