Skip to content

[WebUI] Fix dangling pointer when saving the gateway password - #2408

Merged
1technophile merged 1 commit into
1technophile:developmentfrom
pwsh:fix/webui-gateway-password
Oct 12, 2026
Merged

1technophile merged 1 commit into
1technophile:developmentfrom
pwsh:fix/webui-gateway-password

Conversation

@pwsh

@pwsh pwsh commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Description:

When the gateway password is saved on the Configure WebUI page (/cg), handleCG() did:

const char* gp = server.arg("gp").c_str();

WebServer::arg() returns a String by value, so that temporary is destroyed at the end of the statement and gp points to freed memory (heap, or the String's inline buffer for short passwords). The following strlen(gp) and strcpy(ota_pass, gp) read memory that is no longer owned. It usually works because nothing reuses that memory in between, but it can store a wrong password or a wrong length. GCC reports it as -Wdangling-pointer once the env's -w is removed.

The fix keeps the String in a local variable and uses gp.length() and gp.c_str(). The length check and the behaviour are unchanged.

Built lilygo-rtl_433-fsk with the default flags, and with -w removed and -Wall added: the -Wdangling-pointer warnings at this spot are gone and the change adds no new warning. Not tested on hardware, because that would mean changing a gateway's password.

Checklist:

  • The pull request is done against the latest development branch
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • I accept the DCO.

🤖 Generated with Claude Code

server.arg() returns a String by value, so the pointer from c_str()
pointed into a temporary that was destroyed before strlen()/strcpy().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@1technophile

Copy link
Copy Markdown
Owner

Thanks

@1technophile
1technophile merged commit eb1e7c7 into 1technophile:development Oct 12, 2026
90 checks passed
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