Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Scripting: prevent use of closed network socket #26173

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

tridge
Copy link
Contributor

@tridge tridge commented Feb 8, 2024

this gives a lua exception if you try to do this:

 sock:recv(1024)
 sock:close()
 sock:recv(1024)

without this we dereference null, causing a crash
initially noticed by @magicrub

this prevents a null pointer dereference after a close of a network
socket
@magicrub
Copy link
Contributor

magicrub commented Feb 8, 2024

With this change, do we still need to set it to nil?

@tridge
Copy link
Contributor Author

tridge commented Feb 9, 2024

With this change, do we still need to set it to nil?

yes. This PR means you will get a scripting exception that will stop the script if you use a socket after closing it. Previously it could cause the board to reboot

@IamPete1
Copy link
Member

IamPete1 commented Feb 9, 2024

I had a quick look if we could nul the object, but it seems not. https://stackoverflow.com/questions/49582545/set-lua-obj-to-nil-from-c

@tridge tridge merged commit 5d789f4 into ArduPilot:master Feb 13, 2024
93 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 4.5.0-beta2
Development

Successfully merging this pull request may close these issues.

3 participants