Skip to content

Conversation

hierophect
Copy link
Collaborator

The Common-Hal API for Socket had some inconsistencies argument size and type between functions, such as the "port" argument. Some of these were even using uint8_t, which is far too small for many common port values. This PR converts all arguments to uint32_t and adds some sign checking since Python always passes them in as signed ints.

Further down the line, it may be appropriate to add more comprehensive input sanitation to this and other shared-bindings implementations.

Resolves #4127

@dhalbert
Copy link
Collaborator

dhalbert commented Feb 5, 2021

@tannewt for background, I had a long chat with @hierophect on discord in #circuitpython about this. I think this PR does some good cleanup. Some general-purpose validation routines could be added, say in a top-level shared-bindings/util.c or whatever.

@hierophect looks like you need a (maybe) merge from upstream and definitely make translate.

@hierophect
Copy link
Collaborator Author

I even made a note to do the translate this time and I somehow forgot anyway

@StarWitch
Copy link

Thanks for the quick turnaround! I built this branch and flashed it onto my FeatherS2 and it works just fine, at least for socket.sendto().

@tannewt tannewt removed their request for review February 5, 2021 19:46
@tannewt
Copy link
Member

tannewt commented Feb 5, 2021

Fine by me! @dhalbert please review.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for cleaning this up!

@dhalbert dhalbert merged commit be500fd into adafruit:main Feb 8, 2021
@hierophect hierophect deleted the socket-portmax branch February 8, 2021 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Socketpool socket.sendto() cannot send UDP data to ports above 255
4 participants