commit 53e553e8ded01524f60c018b2266acc39af30669 from: Omar Polo date: Sun Feb 19 10:42:12 2023 UTC tweak send_zero_refs; use GOT_SHA1_STRING_ZERO ok stsp@ commit - d952957db624ae4f22a8bf310c4ab918f3a9dbd3 commit + 53e553e8ded01524f60c018b2266acc39af30669 blob - d21d2a42eb07a9427920b7bc02e980a4ee9a5a22 blob + 6c99eff905aa3c5690f4a529dab7f51cd058b715 --- lib/serve.c +++ lib/serve.c @@ -221,17 +221,11 @@ static const struct got_error * send_zero_refs(int outfd, int client_is_reading, int chattygot) { const struct got_error *err = NULL; + const char *line = GOT_SHA1_STRING_ZERO " capabilities^{}"; char buf[GOT_PKT_MAX]; - uint8_t zero[SHA1_DIGEST_LENGTH]; - char hex[SHA1_DIGEST_STRING_LENGTH]; size_t len, capalen = 0; - - memset(&zero, 0, sizeof(zero)); - if (got_sha1_digest_to_str(zero, hex, sizeof(hex)) == NULL) - return got_error(GOT_ERR_BAD_OBJ_ID); - - len = snprintf(buf, sizeof(buf), "%s capabilities^{}", hex); + len = strlcpy(buf, line, sizeof(buf)); if (len >= sizeof(buf)) return got_error(GOT_ERR_NO_SPACE);