You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "JosiahWI (via GitHub)" <gi...@apache.org> on 2024/06/14 16:18:04 UTC
[PR] Fix use of uninitialized stack memory in records [trafficserver]
JosiahWI opened a new pull request, #11450:
URL: https://github.com/apache/trafficserver/pull/11450
Fixes #11449.
This adds an overload of `RecGetRecordString` that takes an out-parameter for the size of the content copied into the out buffer. It updates `RecHTTPLoadIpAddrsFromConfVars` to use this parameter to get the buffer size to use when initializing the TextView for parsing, so that we only parse the actual content and ignore the uninitialized part of the buffer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on code in PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#discussion_r1641593963
##########
src/records/RecHttp.cc:
##########
@@ -150,7 +151,7 @@ RecHttpLoadIpAddrsFromConfVar(const char *value_name, swoc::IPRangeSet &addrs)
if (REC_ERR_OKAY == RecGetRecordString(value_name, value, sizeof(value))) {
Debug("config", "RecHttpLoadIpAddrsFromConfVar: parsing the name [%s] and value [%s]", value_name, value);
- swoc::TextView text(value);
+ swoc::TextView text(value, std::strlen(value));
Review Comment:
True. `strlen` should be fine.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2169977000
Should be good now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2169903600
This fix is incorrect and introduces a buffer overflow vulnerability because `strlcpy` returns the total length of the source string, not the destination string.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI merged PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "cmcfarlen (via GitHub)" <gi...@apache.org>.
cmcfarlen commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2411958126
Cherry-picked to v10.0.x for #11464
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on code in PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#discussion_r1641425972
##########
src/records/RecHttp.cc:
##########
@@ -150,7 +151,7 @@ RecHttpLoadIpAddrsFromConfVar(const char *value_name, swoc::IPRangeSet &addrs)
if (REC_ERR_OKAY == RecGetRecordString(value_name, value, sizeof(value))) {
Debug("config", "RecHttpLoadIpAddrsFromConfVar: parsing the name [%s] and value [%s]", value_name, value);
- swoc::TextView text(value);
+ swoc::TextView text(value, std::strlen(value));
Review Comment:
Can we use this even though it's part of the C standard and not part of the C++ standard? https://en.cppreference.com/w/cpp/string/byte/strlen
The rest of records uses `strlen(str)` after calling `RecGetRecordString` and this is safe because it's guaranteed to always null-terminate the buffer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2169972790
[approve ci rat]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "ywkaras (via GitHub)" <gi...@apache.org>.
ywkaras commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2173925558
Both GCC and CLang seem to be very good at evaluation strlen for string constants at runtime: https://godbolt.org/z/fqnd5Pb4n .
So, we should change TextView and remove the complicated attempts to avoid calling strlen.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2168435922
[approve ci rocky]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "bneradt (via GitHub)" <gi...@apache.org>.
bneradt commented on code in PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#discussion_r1641375161
##########
src/records/RecHttp.cc:
##########
@@ -150,7 +151,7 @@ RecHttpLoadIpAddrsFromConfVar(const char *value_name, swoc::IPRangeSet &addrs)
if (REC_ERR_OKAY == RecGetRecordString(value_name, value, sizeof(value))) {
Debug("config", "RecHttpLoadIpAddrsFromConfVar: parsing the name [%s] and value [%s]", value_name, value);
- swoc::TextView text(value);
+ swoc::TextView text(value, std::strlen(value));
Review Comment:
Probably better to favor `strnlen(value, 1024)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "ywkaras (via GitHub)" <gi...@apache.org>.
ywkaras commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2173953147
The template overload for C string literals doesn't seem to work anyway: https://godbolt.org/z/5cTWxYq9v
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix use of uninitialized stack memory in records [trafficserver]
Posted by "JosiahWI (via GitHub)" <gi...@apache.org>.
JosiahWI commented on PR #11450:
URL: https://github.com/apache/trafficserver/pull/11450#issuecomment-2170127563
[approve ci]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org