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

Wrong memory allocation size for string copy at load_balancer_api.cc #36610

Closed
apach301 opened this issue May 14, 2024 · 1 comment
Closed

Wrong memory allocation size for string copy at load_balancer_api.cc #36610

apach301 opened this issue May 14, 2024 · 1 comment

Comments

@apach301
Copy link

Hi,
I found a wrong memory allocation during a string copy with Svace static analyzer.

During a string copy in GrpcLbLoadReportRequestCreate() the result of strlen is used to allocate memory, but it is not count a null terminating symbol:

const size_t token_len = strlen(cur.token.get());
char* token = reinterpret_cast<char*>(upb_Arena_Malloc(arena, token_len));
memcpy(token, cur.token.get(), token_len);

@markdroth
Copy link
Member

The existing code is correct. As you can see in your PR, the tests fail with the proposed change.

@markdroth markdroth closed this as not planned Won't fix, can't repro, duplicate, stale May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants