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

Possible access to dangling pointer in yarpbroker.cpp #3105

Open
S-Dafarra opened this issue Apr 17, 2024 · 2 comments
Open

Possible access to dangling pointer in yarpbroker.cpp #3105

S-Dafarra opened this issue Apr 17, 2024 · 2 comments

Comments

@S-Dafarra
Copy link
Contributor

Describe the bug
While reading the code to understand the issue behind #3104, I came across a warning by the Visual Studio static analyzer.

In particular, the following lines

Bottle msg, response;
msg.fromString(request);
ret = port.write(msg, response);
NetworkBase::disconnect(port.getName(), szport);
if(!response.size() || !ret) {
port.close();
return nullptr;
}
port.close();
return response.toString().c_str();

return a pointer to the char buffer of a temporary string.

Configuration (please complete the following information):

  • OS:
  • yarp version: 3.9.0
  • compiler:

Additional context
Add any other context about the problem here.

cc @randaz81

@randaz81
Copy link
Member

Probably fixed. Can you give it a check @S-Dafarra ?

@S-Dafarra
Copy link
Contributor Author

S-Dafarra commented Aug 30, 2024

I believe it should be fixed, thanks a lot! I noticed that there is the c_str() in https://github.com/randaz81/yarp/blob/a62e65eb9ab1906a8e29e947e04629df20293d2c/src/libYARP_manager/src/yarp/manager/yarpbroker.cpp#L575, but since the method outputs a string by copy, it should not be an issue anymore.

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

No branches or pull requests

2 participants