From patchwork Tue May 5 09:53:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= X-Patchwork-Id: 11528583 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 93C7C139F for ; Tue, 5 May 2020 09:53:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B344206CC for ; Tue, 5 May 2020 09:53:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LcebYPD5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728268AbgEEJxe (ORCPT ); Tue, 5 May 2020 05:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725766AbgEEJxe (ORCPT ); Tue, 5 May 2020 05:53:34 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F89AC061A0F for ; Tue, 5 May 2020 02:53:34 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id z6so604161plk.10 for ; Tue, 05 May 2020 02:53:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W908UAuysw5MqFGdzt6EEgAK/TIINEp2lMzjQKFLtu0=; b=LcebYPD5fR6ESrUM5/bgeShA07QNG45cc9squhvGozn3dHUKz8P86iFxyMqAqqm/ws TQ3xhH77z5a0yiq5DFCANmng2p2CDGp/oD7KsON6av2qVUmEIuF7oOzauE4fKZ0eWo7s 1OzBd5YrnFs+qIeIeZ3ti8vET/myIfI9I914sxxy7KRYFs41GFsbn42grWpWmpigdPT1 UkLWMihFbOFoxI8phZBm0tbSufBOJ9mtI1Eh8t0EiFQutIgQtUkrTcO6eYz+m4z5f0lY iRmO2DxALqRb8pMt2xLRrq/uU3YbfaWeCvxT6e3G8Qd08eGqUIefXblO+qEn2qX5oajX d2+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W908UAuysw5MqFGdzt6EEgAK/TIINEp2lMzjQKFLtu0=; b=rRUn8vXJexT/euFvsXzUqr7/afPsw6OECK81AtyDUXNV3G/ShezpGen4Lh3lLPY2nf SJygP/RDJgNdlkUzzKb2oCqVq0fKnibNywhApfeHP4Y912CXghIXy86diHuNt99GnVf9 qFPedLdVL0p9hzHux7KhUtQcf6y37R/rjD4fIGPHuyhw+pEdzZfjKPLsH8NHj/msAN8K 7ECmH4Ces/y9ZC4V81K+S8yF3xKt/k1dL8DIz9F0ki9fzOQkYkA9708D+//G5JwN+0Tq ByaMBC/dDs0aUGfvM7y2DjauLhuG05eRxYCOURE53XaIfEp+DF/5VnoYf8ttMZqip4k/ inSA== X-Gm-Message-State: AGi0Pubdf6hs/CF4UScaug9sEJYk8iDwLd1e9tN7GyN+Wlwxq18/6CaO 2m/JxA42brbFjOUX0a6pzwIlRTod X-Google-Smtp-Source: APiQypLSBuEey4Upj0BLD10mjJZR1Wp2oNxpeop6M5dIqGOjDIf03He6Xtj09uBNhTC2/wAfoRU5ig== X-Received: by 2002:a17:90a:840e:: with SMTP id j14mr1881363pjn.85.1588672413188; Tue, 05 May 2020 02:53:33 -0700 (PDT) Received: from localhost.localdomain (c-67-188-192-166.hsd1.ca.comcast.net. [67.188.192.166]) by smtp.gmail.com with ESMTPSA id h14sm1565094pfq.46.2020.05.05.02.53.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 May 2020 02:53:32 -0700 (PDT) From: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= To: git@vger.kernel.org Cc: sandals@crustytoothpaste.net, =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= Subject: [PATCH v2] builtin/receive-pack: avoid generic function name hmac() Date: Tue, 5 May 2020 02:53:26 -0700 Message-Id: <20200505095326.36374-1-carenas@gmail.com> X-Mailer: git-send-email 2.26.2.686.gfaf46a9ccd In-Reply-To: <20200505054630.5821-1-carenas@gmail.com> References: <20200505054630.5821-1-carenas@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org fabec2c5c3 (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 --- v2 * cleaner commit message that even has an SOB builtin/receive-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) base-commit: af6b65d45ef179ed52087e80cb089f6b2349f4ec diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 2cc18bbffd..39b0c3d70b 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -418,7 +418,7 @@ static int copy_to_sideband(int in, int out, void *arg) return 0; } -static void hmac(unsigned char *out, +static void hmac_hash(unsigned char *out, const char *key_in, size_t key_len, const char *text, size_t text_len) { @@ -463,10 +463,10 @@ static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp) unsigned char hash[GIT_MAX_RAWSZ]; strbuf_addf(&buf, "%s:%"PRItime, path, stamp); - hmac(hash, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed)); + hmac_hash(hash, buf.buf, buf.len, cert_nonce_seed, strlen(cert_nonce_seed)); strbuf_release(&buf); - /* RFC 2104 5. HMAC-SHA1-80 */ + /* RFC 2104 5. HMAC-SHA1 or HMAC-SHA256 */ strbuf_addf(&buf, "%"PRItime"-%.*s", stamp, (int)the_hash_algo->hexsz, hash_to_hex(hash)); return strbuf_detach(&buf, NULL); }