| 385 | } |
| 386 | |
| 387 | static const char *find_packfile_uri_path(const char *buffer) |
| 388 | { |
| 389 | const char *URI_MARK = "://"; |
| 390 | const char *path; |
| 391 | int len; |
| 392 | |
| 393 | /* First char is sideband mark */ |
| 394 | buffer += 1; |
| 395 | |
| 396 | len = strspn(buffer, "0123456789abcdefABCDEF"); |
| 397 | /* size of SHA1 and SHA256 hash */ |
| 398 | if (!(len == 40 || len == 64) || buffer[len] != ' ') |
| 399 | return NULL; /* required "<hash>SP" not seen */ |
| 400 | |
| 401 | path = strstr(buffer + len + 1, URI_MARK); |
| 402 | if (!path) |
| 403 | return NULL; |
| 404 | |
| 405 | path = strchr(path + strlen(URI_MARK), '/'); |
| 406 | if (!path || !*(path + 1)) |
| 407 | return NULL; |
| 408 | |
| 409 | /* position after '/' */ |
| 410 | return ++path; |
| 411 | } |
| 412 | |
| 413 | enum packet_read_status packet_read_with_status(int fd, char **src_buffer, |
| 414 | size_t *src_len, char *buffer, |
no outgoing calls
no test coverage detected