-
Couldn't load subscription status.
- Fork 177
Add opentelemetry_resource_attr #566
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1051,6 +1051,21 @@ char* OtelNgxSetTracesSamplerRatio(ngx_conf_t* cf, ngx_command_t*, void*) { | |||||||||||||||||||||||||||||
| return NGX_CONF_OK; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| char* OtelNgxSetResourceAttr(ngx_conf_t* cf, ngx_command_t*, void*) { | ||||||||||||||||||||||||||||||
| OtelMainConf* otelMainConf = GetOtelMainConf(cf); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| if (cf->args->nelts < 3) { | |
| ngx_log_error(NGX_LOG_ERR, cf->log, 0, "opentelemetry: invalid number of arguments for resource attribute. Expected 2 arguments (key and value)."); | |
| return (char*)NGX_CONF_ERROR; | |
| } |
Copilot
AI
Jul 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key and value strings are constructed without null-termination validation. If key->data or value->data are not null-terminated within the specified length, this could lead to buffer overruns when used elsewhere.
| std::string strKey((const char*)key->data, key->len); | |
| std::string strValue((const char*)value->data, value->len); | |
| std::string strKey; | |
| std::string strValue; | |
| { | |
| std::vector<char> keyBuffer(key->data, key->data + key->len); | |
| keyBuffer.push_back('\0'); // Ensure null-termination | |
| strKey = std::string(keyBuffer.data()); | |
| } | |
| { | |
| std::vector<char> valueBuffer(value->data, value->data + value->len); | |
| valueBuffer.push_back('\0'); // Ensure null-termination | |
| strValue = std::string(valueBuffer.data()); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be an unrelated formatting fix (adding missing semicolon) that should be mentioned in the PR description or handled in a separate commit.