Skip to content

Commit 3013118

Browse files
carenasgitster
authored andcommitted
builtin/receive-pack: avoid generic function name hmac()
fabec2c (builtin/receive-pack: switch to use the_hash_algo, 2019-08-18) renames hmac_sha1 to hmac, as it was updated to use the hash function used by git (which won't be sha1 in the future). hmac() is provided by NetBSD >= 8 libc and therefore conflicts as shown by : builtin/receive-pack.c:421:13: error: conflicting types for 'hmac' static void hmac(unsigned char *out, ^~~~ In file included from ./git-compat-util.h:172:0, from ./builtin.h:4, from builtin/receive-pack.c:1: /usr/include/stdlib.h:305:10: note: previous declaration of 'hmac' was here ssize_t hmac(const char *, const void *, size_t, const void *, size_t, void *, ^~~~ Rename it again to hmac_hash to reflect it will use the git's defined hash function and avoid the conflict, while at it update a comment to better describe the HMAC function that was used. Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b86a4be commit 3013118

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

builtin/receive-pack.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static int copy_to_sideband(int in, int out, void *arg)
417417
return 0;
418418
}
419419

420-
static void hmac(unsigned char *out,
420+
static void hmac_hash(unsigned char *out,
421421
const char *key_in, size_t key_len,
422422
const char *text, size_t text_len)
423423
{
@@ -462,10 +462,10 @@ static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
462462
unsigned char hash[GIT_MAX_RAWSZ];
463463

464464
strbuf_addf(&buf, "%s:%"PRItime, path, stamp);
465-
hmac(hash, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed));
465+
hmac_hash(hash, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed));
466466
strbuf_release(&buf);
467467

468-
/* RFC 2104 5. HMAC-SHA1-80 */
468+
/* RFC 2104 5. HMAC-SHA1 or HMAC-SHA256 */
469469
strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, hash_to_hex(hash));
470470
return strbuf_detach(&buf, NULL);
471471
}

0 commit comments

Comments
 (0)