Skip to content

Missing history length check in ScreenTerminal #1206

@Elec332

Description

@Elec332

The setSize() function in ScreenTerminal https://github.com/jline/jline3/blob/master/builtins/src/main/java/org/jline/builtins/ScreenTerminal.java#L1614 resizes the screen as required.
When the screen height gets increased after being decreased, the function will "reinstate" a few history lines.

Where all the original line are increased in length to be (at least) the proper width with Arrays.copyOf() (https://github.com/jline/jline3/blob/master/builtins/src/main/java/org/jline/builtins/ScreenTerminal.java#L1622), the length of the historic lines is never checked: https://github.com/jline/jline3/blob/master/builtins/src/main/java/org/jline/builtins/ScreenTerminal.java#L1660

As a sizenote:
When the array in increased in size with Array.copyOf(), the rest of the array is initialized with 0's, instead of attr | 0x00000020 (space), so there will be width issues when rendering them as AttributedStrings, as a null char has no width

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions