Skip to content

Fix stack buffer overflows in ngc_flowctrl.c#989

Closed
94xhn wants to merge 1 commit into
grblHAL:masterfrom
94xhn:fix/flowctrl-stack-overflow
Closed

Fix stack buffer overflows in ngc_flowctrl.c#989
94xhn wants to merge 1 commit into
grblHAL:masterfrom
94xhn:fix/flowctrl-stack-overflow

Conversation

@94xhn

@94xhn 94xhn commented Jul 18, 2026

Copy link
Copy Markdown

This patch fixes two stack buffer overflow vulnerabilities inside
gc_flowctrl.c\ where long user G-code subprogram/macro names retrieved via
gc_string_param_get\ could overflow stack buffers \msg[100]\ and \ ilename[60]. 1. In \onNamedSubError, the error message was formatted using \sprintf(msg, ...)\ where \msg\ is only 100 bytes long, while string parameters can be up to 255 bytes. 2. In the \NGCFlowCtrl_Call\ handler, macro filenames were formatted using \sprintf(filename, ...)\ where \ ilename\ is only 60 bytes long. These are resolved by replacing unsafe \sprintf\ calls with bounds-checked \snprintf.

Signed-off-by: yi chen <94xhn1@gmail.com>
@terjeio

terjeio commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Instead of failing long names I have instead changed the code to use heap to store them temporarily. Can you please confirm that this fixes your issue in a more graceful way? BTW be aware that the underlying file system may impose its own restrictions on filename lengths...

@terjeio terjeio closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants