From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff King Subject: Re: [PATCH] config: don't segfault when given --path with a missing value Date: Thu, 15 Nov 2012 08:18:01 -0800 Message-ID: <20121115161758.GC6157@sigill.intra.peff.net> References: <1352868604-20459-1-git-send-email-cmn@elego.de> <20121115160847.GA6157@sigill.intra.peff.net> <20121115161149.GB6157@sigill.intra.peff.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: git@vger.kernel.org To: Carlos =?utf-8?Q?Mart=C3=ADn?= Nieto X-From: git-owner@vger.kernel.org Thu Nov 15 17:18:27 2012 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TZ28z-0005ag-3g for gcvg-git-2@plane.gmane.org; Thu, 15 Nov 2012 17:18:21 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1768373Ab2KOQSG (ORCPT ); Thu, 15 Nov 2012 11:18:06 -0500 Received: from 75-15-5-89.uvs.iplsin.sbcglobal.net ([75.15.5.89]:49515 "EHLO peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1768367Ab2KOQSF (ORCPT ); Thu, 15 Nov 2012 11:18:05 -0500 Received: (qmail 17564 invoked by uid 107); 15 Nov 2012 16:18:53 -0000 Received: from m8c0536d0.tmodns.net (HELO sigill.intra.peff.net) (208.54.5.140) (smtp-auth username relayok, mechanism cram-md5) by peff.net (qpsmtpd/0.84) with ESMTPA; Thu, 15 Nov 2012 11:18:53 -0500 Received: by sigill.intra.peff.net (sSMTP sendmail emulation); Thu, 15 Nov 2012 08:18:01 -0800 Content-Disposition: inline In-Reply-To: <20121115161149.GB6157@sigill.intra.peff.net> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Thu, Nov 15, 2012 at 08:11:50AM -0800, Jeff King wrote: > Hmm, actually, we should probably propagate the error (I was thinking > for some reason this was in the listing code, but it is really about > getting a specific variable, and that variable does not have a sane > format. We'll already have printed the non-bool error, so we should > probably die. So more like: > > if (git_config_pathname(&vptr, key_, value_) < 0) > return -1; > must_free_vptr = 1; You may want to squash in this test, which triggers your original problem, but also demonstrates the use of uninitialized memory (although you need to run under valgrind or similar to reliably notice it). diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index e127f35..7c4c372 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -803,6 +803,11 @@ test_expect_success NOT_MINGW 'get --path copes with unset $HOME' ' test_cmp expect result ' +test_expect_success 'get --path barfs on boolean variable' ' + echo "[path]bool" >.git/config && + test_must_fail git config --get --path path.bool +' + cat > expect << EOF [quote] leading = " test" -Peff