bryancall commented on code in PR #12717:
URL: https://github.com/apache/trafficserver/pull/12717#discussion_r2879997008
##########
src/iocore/cache/CacheHosting.cc:
##########
@@ -740,17 +743,33 @@ ConfigVolumes::BuildListFromString(char
*config_file_path, char *file_buf)
in_percent = 0;
}
} else if (strcasecmp(tmp, "avg_obj_size") == 0) { // match avg_obj_size
- tmp += 13;
- avg_obj_size = atoi(tmp);
+ tmp += 13;
+ if (!ParseRules::is_digit(*tmp)) {
+ err = "Invalid avg_obj_size value (must start with a number, e.g.,
64K)";
+ break;
+ }
+ avg_obj_size = static_cast<int>(ink_atoi64(tmp));
- while (ParseRules::is_digit(*tmp)) {
+ if (avg_obj_size < 0) {
+ err = "Invalid avg_obj_size value (must be >= 0)";
+ break;
+ }
Review Comment:
`ink_atoi64` only recognizes uppercase suffixes (`K`, `M`, `G`, `T`), but
this skip loop accepts both cases via `strchr("kmgtKMGT", *tmp)`. If someone
writes `ram_cache_size=2g`, `ink_atoi64` returns `2` (no multiplier applied),
the skip loop eats the `g`, and the volume silently gets a 2-byte RAM cache
allocation.
Either restrict the skip to uppercase only:
```cpp
while (*tmp && (ParseRules::is_digit(*tmp) || strchr("KMGT", *tmp))) {
```
Or better, reject lowercase with an error. Same issue applies to
`ram_cache_cutoff`, `avg_obj_size`, and `fragment_size` parsing.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]