bryancall commented on code in PR #12717:
URL: https://github.com/apache/trafficserver/pull/12717#discussion_r2879997311
##########
src/proxy/http/remap/RemapConfig.cc:
##########
@@ -1197,12 +1209,55 @@ remap_parse_config_bti(const char *path,
BUILD_TABLE_INFO *bti)
if ((bti->remap_optflg & REMAP_OPTFLG_MAP_ID) != 0) {
int idx = 0;
int ret = remap_check_option(bti->argv, bti->argc, REMAP_OPTFLG_MAP_ID,
&idx);
+
if (ret & REMAP_OPTFLG_MAP_ID) {
- char *c = strchr(bti->argv[idx], static_cast<int>('='));
+ char *c = strchr(bti->argv[idx], static_cast<int>('='));
+
new_mapping->map_id = static_cast<unsigned int>(atoi(++c));
}
}
+ // Parse @volume= option with comma-separated syntax (@volume=3,4)
+ for (int i = 0; i < bti->argc; i++) {
+ if (!strncasecmp(bti->argv[i], "volume=", 7)) {
+ const char *volume_str = &bti->argv[i][7];
+
+ if (!volume_str || !*volume_str) {
+ snprintf(errStrBuf, sizeof(errStrBuf), "Empty @volume= directive at
line %d", cln + 1);
+ errStr = errStrBuf;
+ goto MAP_ERROR;
+ }
+
+ for (const char *p = volume_str; *p; p++) {
+ if (*p != ',' && (*p < '0' || *p > '9')) {
+ snprintf(errStrBuf, sizeof(errStrBuf), "Invalid character '%c' in
@volume=%s at line %d", *p, volume_str, cln + 1);
+ errStr = errStrBuf;
Review Comment:
This character-level validation allows degenerate inputs: `@volume=,,`,
`@volume=0`, `@volume=,1,`, `@volume=999`. For the eager path (cache ready),
`createCacheHostRecord()` catches bad volume numbers. But for the deferred path
(initial startup), the string is stored as-is and errors only surface later as
a non-fatal `Error()` log — the remap rule silently runs without a volume
override.
Consider adding lightweight range validation here (split on commas, verify
each number is 1–255, reject empty segments).
--
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]