commit - fd1b27119fe0bafd2e0b5ee26e877c742edfeb0e
commit + bcf7cd444a9e9057ce6f48cfb03573b4972d7559
blob - 02951a4033a9780646d80ed187c221487167e497
blob + d3283c409607632e6832eeae310b43f122ea16ba
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
fwrite(buf, 1, r, stdout);
+ t = 0;
n = 0;
- while (verbose && n + 4 < r) {
+ while (n + 4 <= r) {
buf[n + 4] = '\0';
t = hexstrtonum(&buf[n], 0, sizeof(buf) - n, &errstr);
if (errstr != NULL) {
- warnx("pktline len is %s", errstr);
+ fprintf(stderr, "pktline len is %s", errstr);
goto err;
+ }
+
+ if (t == 0) {
+ if (verbose) {
+ fprintf(stderr, "%s: readpkt: 0000\n",
+ getprogname());
+ }
+ break;
}
if (t < 6) {
- warnx("pktline len is too small");
+ fprintf(stderr, "pktline len is too small");
goto err;
}
- fprintf(stderr, "%s: readpkt: %lld:\t",
- getprogname(), t - 4);
- for (i = 5; i < t; i++) {
- if (isprint((unsigned char)buf[n + i]))
- fputc(buf[n + i], stderr);
- else
- fprintf(stderr, "[0x%.2x]", buf[n + i]);
+ if (verbose) {
+ fprintf(stderr, "%s: readpkt: %lld:\t",
+ getprogname(), t - 4);
+ for (i = 5; i < t; i++) {
+ if (isprint((unsigned char)buf[n + i]))
+ fputc(buf[n + i], stderr);
+ else
+ fprintf(stderr, "[0x%.2x]",
+ buf[n + i]);
+ }
+ fputc('\n', stderr);
}
- fputc('\n', stderr);
n += t;
}
+ if (t == 0)
+ break;
}
fflush(stdout);