Skip to content

Buffer overun in layer names #165

@peterjc

Description

@peterjc

Describe the bug

The layer display-name as per https://zmk.dev/docs/keymaps#layers-1 has no explicit upper length limit. Creating ZMK firmware with long names works, but displays strangely in ZMK Studio 0.3.1 suggestive of a buffer overrun as if the name is limited to 20 characters.

To Reproduce
Steps to reproduce the behavior:

  1. Build firmware with multiple layers with display-name over 20 chars
  2. Flash to keyboard
  3. Connect to ZMK Studio
  4. The expected long names are truncated at 20 chars, but run on into the first 20 chars of subequent layers, until reaching a short layer (and I assume a terminating null).

Expected behavior

Names to be hard limited at 20 characters, or shown in full.

I am unclear if this is a ZMK limit and/or a ZMK Studio limit. If a ZMK limit, then Studio could guard against the buffer overrun using the known limit.

Note I have not checked what happens if the final layer has a long name - Studio may show random data...

Screenshots

Image

Here the three layers starting "D5" had overly long names (trying a layer trick as a proxy for tracking if the last letter was on the left or right for a magic key like behaviours giving space or repeat, see currently empty D5 layout repository).

Environment (please complete the following information):

  • OS: macOS
  • Browser or App [e.g. chrome, edge, app]: app
  • Version [e.g. 22]: 0.3.1
  • Device [e.g. Corne with nice!nano v2]: Gamma Omega TC36K (RP2040 Pico).

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions