commit 04c53c18246515277f8f093309035e992273819d from: Stefan Sperling date: Wed Mar 18 16:11:31 2020 UTC make got-fetch-pack check for NAK from server before the packfile arrives commit - 3b9fb5855a164a4eddcd66f327336c34f8948869 commit + 04c53c18246515277f8f093309035e992273819d blob - 312015a9368f1d111fb38a9cab8e8e1efef0949b blob + 506a18dece417978b0b5c833aa9365cdf7a218a1 --- libexec/got-fetch-pack/got-fetch-pack.c +++ libexec/got-fetch-pack/got-fetch-pack.c @@ -584,7 +584,14 @@ fetch_pack(int fd, int packfd, struct got_object_id *p err = readpkt(&n, fd, buf, sizeof(buf)); if (err) goto done; - buf[n] = 0; + /* + * For now, we only support a full clone, in which case the server + * will now send a "NAK" (meaning no common objects were found). + */ + if (n != 4 || strncmp(buf, "NAK\n", n) != 0) { + err = got_error(GOT_ERR_BAD_PACKET); + goto done; + } if (chattygit) fprintf(stderr, "fetching...\n");