From: Stefan Sperling Subject: fix got-fetch-http 'done' hack To: gameoftrees@openbsd.org Date: Fri, 19 Apr 2024 21:07:04 +0200 This avoids an unexpected early EOF error in got-fetch-pack. ok? ----------------------------------------------- make got-fetch-http pass "done\n" through rather than faking it Without this we exit the loop early and got-fetch-pack sees unexpected end-of-file on stdout trying to write its final "done\n" message. diff 7e03b4680df5ee2238eb8918276b9ef7130dd115 5600af0d4cd13d830b95b49bea10879efb968794 commit - 7e03b4680df5ee2238eb8918276b9ef7130dd115 commit + 5600af0d4cd13d830b95b49bea10879efb968794 blob - a5f2e1b28bbc8c0f51f1f3e9385f4f165dbd0b1b blob + f59556fe906b0a5f6b8f565d12b387c701f2f4c7 --- libexec/got-fetch-http/got-fetch-http.c +++ libexec/got-fetch-http/got-fetch-http.c @@ -466,13 +466,11 @@ upload_request(int https, const char *host, const char goto err; } - /* no idea why 0000 is not enough. */ if (t == 0) { - const char *x = "00000009done\n"; - if (http_chunk(&bio, x, strlen(x)) || - http_chunk(&bio, NULL, 0)) + const char *flushpkt = "0000"; + if (http_chunk(&bio, flushpkt, strlen(flushpkt))) goto err; - break; + continue; /* got-fetch-pack will send "done" */ } if (t < 6) { @@ -486,6 +484,16 @@ upload_request(int https, const char *host, const char if (http_chunk(&bio, buf, t)) goto err; + + /* + * Once got-fetch-pack is done the server will + * send pack file data. + */ + if (t == 9 && strncmp(buf + 4, "done\n", 5) == 0) { + if (http_chunk(&bio, NULL, 0)) + goto err; + break; + } } if (http_parse_reply(&bio, &chunked, UPLOAD_PACK_RES) == -1)