Inventory paths are data, never argv or filesystem paths. Unlike blob * lookup, this validates only tree-path structure, retaining every literal * byte spelling so an unsupported relevant entry cannot silently disappear. */
| 1084 | * lookup, this validates only tree-path structure, retaining every literal |
| 1085 | * byte spelling so an unsupported relevant entry cannot silently disappear. */ |
| 1086 | static bool gf_inventory_path(cbm_git_facts_t *facts, const unsigned char *path, size_t n, |
| 1087 | cbm_git_facts_error_t *error) { |
| 1088 | if (!n || path[0] == '/') |
| 1089 | return gf_error(error, CBM_GIT_FACTS_COMMAND, "Malformed tracked-tree path"); |
| 1090 | size_t begin = 0; |
| 1091 | for (size_t i = 0; i <= n; i++) { |
| 1092 | if ((i & 65535u) == 0 && !gf_gate(facts, error)) |
| 1093 | return false; |
| 1094 | if (i != n && path[i] != '/') |
| 1095 | continue; |
| 1096 | size_t length = i - begin; |
| 1097 | if (!length || (length == 1 && path[begin] == '.') || |
| 1098 | (length == 2 && path[begin] == '.' && path[begin + 1] == '.')) |
| 1099 | return gf_error(error, CBM_GIT_FACTS_COMMAND, "Malformed tracked-tree path"); |
| 1100 | begin = i + 1; |
| 1101 | } |
| 1102 | return true; |
| 1103 | } |
| 1104 | |
| 1105 | /* Parse one exact <mode> <type> <full-oid> TAB <path> NUL record. Bounds |
| 1106 | * come from captured length, never a guessed line or a strlen(path). */ |
no test coverage detected