| 306 | } |
| 307 | |
| 308 | static char *agent_trim_copy(const char *start, size_t length) { |
| 309 | while (length > 0U && isspace((unsigned char)*start)) { |
| 310 | start++; |
| 311 | length--; |
| 312 | } |
| 313 | while (length > 0U && isspace((unsigned char)start[length - 1U])) { |
| 314 | length--; |
| 315 | } |
| 316 | if (length >= 2U && ((start[0] == '"' && start[length - 1U] == '"') || |
| 317 | (start[0] == '\'' && start[length - 1U] == '\''))) { |
| 318 | start++; |
| 319 | length -= 2U; |
| 320 | } |
| 321 | char *copy = (char *)malloc(length + 1U); |
| 322 | if (!copy) { |
| 323 | return NULL; |
| 324 | } |
| 325 | memcpy(copy, start, length); |
| 326 | copy[length] = '\0'; |
| 327 | return copy; |
| 328 | } |
| 329 | |
| 330 | /* Reads only the documented `mcp.mcpConfigPath` scalar. Unsupported aliases, |
| 331 | * block scalars, duplicates, or malformed indentation fail closed. */ |
no outgoing calls
no test coverage detected