From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBA1EC61DA4 for ; Tue, 14 Feb 2023 18:38:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232950AbjBNSiY (ORCPT ); Tue, 14 Feb 2023 13:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232910AbjBNSiT (ORCPT ); Tue, 14 Feb 2023 13:38:19 -0500 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A2322B282 for ; Tue, 14 Feb 2023 10:38:14 -0800 (PST) Received: (qmail 589 invoked by uid 109); 14 Feb 2023 18:38:13 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 14 Feb 2023 18:38:13 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 3679 invoked by uid 111); 14 Feb 2023 18:38:12 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Tue, 14 Feb 2023 13:38:12 -0500 Authentication-Results: peff.net; auth=none Date: Tue, 14 Feb 2023 13:38:12 -0500 From: Jeff King To: Eric Sunshine Cc: Junio C Hamano , =?utf-8?B?5a2f5a2Q5piT?= , git@vger.kernel.org Subject: [PATCH 0/3] get rid of sscanf() when shortening refs Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, Feb 14, 2023 at 12:07:17PM -0500, Jeff King wrote: > There's a leak in it when there is an ambiguous ref (because we allocate > short_name in each iteration of the loop, rather than overwriting the > buffer). I'll post a fixed version in a moment. OK, here it is. I split it into a few patches to hopefully make it a bit easier to follow. [1/3]: shorten_unambiguous_ref(): avoid integer truncation [2/3]: shorten_unambiguous_ref(): use NUM_REV_PARSE_RULES constant [3/3]: shorten_unambiguous_ref(): avoid sscanf() refs.c | 92 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 45 deletions(-) -Peff