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

Implement for ssid a similar approach as for passphrase #5411

Merged
merged 3 commits into from
Dec 3, 2018
Merged

Implement for ssid a similar approach as for passphrase #5411

merged 3 commits into from
Dec 3, 2018

Conversation

devyte
Copy link
Collaborator

@devyte devyte commented Dec 2, 2018

Fixes #2200 (in theory)
Fixes #4911
Replaces #4691
This is not tested. The PR doesn't affect the pre-PR case (ssid up to 31chars). If the implementation doesn't work, and assuming no bug in the approach (same code as for passphrase with 64 bytes), then there is something broken in the SDK, and likely nothing can be done here.

@devyte
Copy link
Collaborator Author

devyte commented Dec 2, 2018

CC @mictlan666 @C0rn3j @liquidfalcon

Copy link
Collaborator

@earlephilhower earlephilhower left a comment

Choose a reason for hiding this comment

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

I can't test this actually fixes the issue, but I don't see anything that would break the normal cases.

@@ -119,10 +119,12 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
}

struct station_config conf;
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
if(strlen(ssid) == 32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

strncpy(reinterpret_cast<char*>(conf.ssid), ssid, 32); will do the same w/o any if required.

From the man page, this is one of the intended uses:

   One  valid  (and  intended) use of strncpy() is to copy a C string to a fixed-length buffer while ensuring both that the buffer is not overflowed and that unused bytes in the target buffer are zeroed out (perhaps to prevent information leaks if the buffer is to be written to media or transmitted to another process via an interprocess communication technique).

@earlephilhower earlephilhower added this to the 2.5.0 milestone Dec 3, 2018
@earlephilhower earlephilhower merged commit 4941711 into esp8266:master Dec 3, 2018
@devyte devyte deleted the issue2200 branch December 3, 2018 19:01
This pull request was closed.
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