commit 9adde3d8b2936f53d7b658c91f627336f563ab23 from: Omar Polo date: Sat Jan 23 17:45:56 2021 UTC reuse the same buffer for the request and response commit - 6cdecad88df2a3f0dca17db0a176bf34d67ade83 commit + 9adde3d8b2936f53d7b658c91f627336f563ab23 blob - b126cca4c099ac3c28afbdb005d196536ed1521a blob + ab67c0cd53f76b99bc448ca9a2d65f5aa6d38140 --- gg.c +++ gg.c @@ -24,7 +24,7 @@ main(int argc, char **argv) struct iri iri; struct tls_config *conf; struct tls *ctx; - char iribuf[GEMINI_URL_LEN], req[GEMINI_URL_LEN], buf[1024]; + char iribuf[GEMINI_URL_LEN], buf[GEMINI_URL_LEN]; const char *parse_err = "unknown error", *port = "1965"; char *t; int ch, flag2, flag3, bflag, cflag, hflag, Nflag, Vflag; @@ -73,9 +73,9 @@ main(int argc, char **argv) if (strlcpy(iribuf, argv[0], sizeof(iribuf)) >= sizeof(iribuf)) errx(1, "request too long: %s", argv[0]); - if (strlcpy(req, argv[0], sizeof(req)) >= sizeof(iribuf)) + if (strlcpy(buf, argv[0], sizeof(buf)) >= sizeof(iribuf)) errx(1, "request too long: %s", argv[0]); - if (strlcat(req, "\r\n", sizeof(req)) >= sizeof(req)) + if (strlcat(buf, "\r\n", sizeof(buf)) >= sizeof(buf)) errx(1, "request too long: %s", argv[0]); if (!parse_iri(iribuf, &iri, &parse_err)) @@ -107,8 +107,8 @@ main(int argc, char **argv) if (tls_connect(ctx, iri.host, port) == -1) errx(1, "tls_connect: %s", tls_error(ctx)); - tls_write(ctx, req, strlen(req)); - /* if (tls_write(ctx, req, strlen(req)) != -1) */ + tls_write(ctx, buf, strlen(buf)); + /* if (tls_write(ctx, buf, strlen(buf)) != -1) */ /* errx(1, "tls_write: %s", tls_error(ctx)); */ for (;;) {