git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Receive-pack: include entire SHA1 in nonce

From
Brian Gernhardt <brian@gernhardtsoftware.com>
Date
Sep 25, 2014, 15:02 UTC
Message-ID
<1411657340-62950-1-git-send-email-brian@gernhardtsoftware.com>
clang gives the following warning:
builtin/receive-pack.c:327:35: error: sizeof on array function
parameter will return size of 'unsigned char *' instead of 'unsigned
char [20]' [-Werror,-Wsizeof-array-argument]
        git_SHA1_Update(&ctx, out, sizeof(out));
                                         ^
builtin/receive-pack.c:292:37: note: declared here
static void hmac_sha1(unsigned char out[20],
                                    ^
---
 I dislike changing sizeof to a magic constant, but clang informs me that
 sizeof is doing the wrong thing.  Perhaps there's an appropriate constant
 #defined in the code somewhere?
 builtin/receive-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index aab3df7..92388e5 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -324,7 +324,7 @@ static void hmac_sha1(unsigned char out[20],
 	/* RFC 2104 2. (6) & (7) */
 	git_SHA1_Init(&ctx);
 	git_SHA1_Update(&ctx, k_opad, sizeof(k_opad));
-	git_SHA1_Update(&ctx, out, sizeof(out));
+	git_SHA1_Update(&ctx, out, 20);
 	git_SHA1_Final(out, &ctx);
 }
 
-- 
2.1.1.445.gb8dfbef.dirty
Next: Junio C Hamano
Message 1 of 5 in “Receive-pack: include entire SHA1 in nonce”
  1. Receive-pack: include entire SHA1 in nonceBrian Gernhardt, Sep 25, 2014
  2. Junio C HamanoSep 25, 2014
  3. Junio C HamanoSep 25, 2014
  4. Junio C HamanoSep 25, 2014
  5. Brian GernhardtSep 25, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.