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

[BUG] Pointer dereferencing issue with authentication (oss & pro) #166

Closed
mathieucarbou opened this issue Nov 22, 2023 · 0 comments · Fixed by #174
Closed

[BUG] Pointer dereferencing issue with authentication (oss & pro) #166

mathieucarbou opened this issue Nov 22, 2023 · 0 comments · Fixed by #174
Assignees

Comments

@mathieucarbou
Copy link
Contributor

mathieucarbou commented Nov 22, 2023

When setting authentication, the function takes a pointer to username / password, and just holds a copy of the pointer in the class but not a copy of the data.

So when the pointer is dereferenced when the caller method finishes, the authenticate method of the HTTP GET handler does not work anymore.

I would suggest doing a safe copy of the data since it is used at another location and not only within the caller method context.

Otherwise, use String.

I've fixed it using String:

header:

private:
  [...]
  String username;
  String password;
  [...]

public:
  [...]
  void setAuthentication(const String &user, const String &pass);
  [...]

cpp

[...]

if(!request->authenticate(username.c_str(), password.c_str()))

[...]

void ESPDash::setAuthentication(const String &user, const String &pass) {
  username = user;
  password = pass;
  basic_auth = true;
  _ws->setAuthentication(username.c_str(), password.c_str());
}

[...]
@mathieucarbou mathieucarbou changed the title [BUG] Pointer dereferencing issue with authentication [BUG] Pointer dereferencing issue with authentication (oss & pro) Nov 25, 2023
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 a pull request may close this issue.

3 participants