Case-insensitive on Windows-style paths, exact elsewhere: NTFS is * case-insensitive, so ".SSH" must not slip past a case-sensitive compare. */
| 106 | /* Case-insensitive on Windows-style paths, exact elsewhere: NTFS is |
| 107 | * case-insensitive, so ".SSH" must not slip past a case-sensitive compare. */ |
| 108 | static bool ws_component_equals(const char *component, size_t len, const char *name, |
| 109 | bool fold_case) { |
| 110 | if (strlen(name) != len) { |
| 111 | return false; |
| 112 | } |
| 113 | for (size_t i = 0; i < len; i++) { |
| 114 | char a = component[i]; |
| 115 | char b = name[i]; |
| 116 | if (fold_case) { |
| 117 | if (a >= 'A' && a <= 'Z') { |
| 118 | a = (char)(a - 'A' + 'a'); |
| 119 | } |
| 120 | if (b >= 'A' && b <= 'Z') { |
| 121 | b = (char)(b - 'A' + 'a'); |
| 122 | } |
| 123 | } |
| 124 | if (a != b) { |
| 125 | return false; |
| 126 | } |
| 127 | } |
| 128 | return true; |
| 129 | } |
| 130 | |
| 131 | /* Directory and file names that carry credentials. Matched against every |
| 132 | * component, so both "…/.ssh" and "…/.ssh/sub" are refused. Additive by design: |
no outgoing calls
no test coverage detected