Skip to content

Commit 14a6f8f

Browse files
committed
menu/rgui: convert OSK fallback messagebox build to strlcpy_append
The fallback path in rgui_render_osk that triggers when the on-screen keyboard cannot fit on the framebuffer was building its message via the unsafe `*pos += strlcpy(buf + *pos, src, len - *pos)` pattern. The construction was sound here because msg is large (NAME_MAX_LENGTH) and inputs are short, but the same string-build shape is what strlcpy_append exists to replace -- it's bound-checked, short-circuits cleanly on truncation, and avoids the off-by-one arithmetic around the embedded '\n'. Mirrors materialui_render's identical construction at materialui.c line ~8091, which was already converted in the strlcpy_append chain-conversion sweeps (commits 25ade82 / e446242 / 78c52ab).
1 parent 0e64839 commit 14a6f8f

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

menu/drivers/rgui.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4786,12 +4786,10 @@ static void rgui_render_osk(
47864786
* If OSK cannot physically fit on the screen,
47874787
* fallback to old style 'message box' implementation */
47884788
char msg[NAME_MAX_LENGTH];
4789-
size_t _len = strlcpy(msg, input_label, sizeof(msg) - 2);
4790-
msg[ _len] = '\n';
4791-
msg[++_len] = '\0';
4792-
strlcpy(msg + _len,
4793-
input_str,
4794-
sizeof(msg) - _len);
4789+
size_t _len = 0;
4790+
strlcpy_append(msg, sizeof(msg), &_len, input_label);
4791+
strlcpy_append(msg, sizeof(msg), &_len, "\n");
4792+
strlcpy_append(msg, sizeof(msg), &_len, input_str);
47954793
rgui_render_messagebox(rgui, msg, fb_width, fb_height);
47964794
return;
47974795
}

0 commit comments

Comments
 (0)