From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 392901FF9C for ; Mon, 26 Oct 2020 16:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1785032AbgJZQJY (ORCPT ); Mon, 26 Oct 2020 12:09:24 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:52926 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1785022AbgJZQJY (ORCPT ); Mon, 26 Oct 2020 12:09:24 -0400 Received: by mail-wm1-f68.google.com with SMTP id c194so12235017wme.2 for ; Mon, 26 Oct 2020 09:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=KQ/Om1iJNa++UOs6ipGuMhVM81spY9yADMMzBFismRs=; b=UkFEPbKrM21h6vEIme2BuyGyOjUZHhnt4g719mNM2Dn4czpIR5jY7NKaVpfkvKayFo IO53CfdrycD952jowHAWdD4IW/xhoEq/Xp/zkSjP/WZ1bErkLOaggN2WX5C0M4pOlx36 7pGNiVQTc5njGwgFvr3zTwlZXZOR4NI0Mh52f9q7LKO2M5UaTqJdda3XHXaIAOavQXjr f7fRztv3lzhsc+sPFhfxRu2TyX0RDg+dkd9DOpXJVJP1cZOolQ2Cg9W0bfNDPTxqRicf NK30+5+z42hVxE5DaejoPRV0unwgoNUK2qhaLegxsgWYCEoRe6ulh2VCa3ucYuS9xBUu +RNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=KQ/Om1iJNa++UOs6ipGuMhVM81spY9yADMMzBFismRs=; b=L7URBveVGgCvxXc8l02KfZqRITGduut/qmKc7808AYgkxY8KPktHbgt7q3YX/KmbKb Y+3rSO2PirVg426TFXlBr3HjA4hBdZ41pS5VifPkavka3I5jrxqf42Rv5/wbVvIRvcWQ o0YgN+NIu/blp3BLzaQ8CqQYWN+KJakcZJ92hOc1CHYbakg2mfRK8HWcukEujyexkf3J /1GAtWK6EdP6IaID0H07DDq6awaoGAaXjnXJSNrjbDAXSacfIOgXb+YEa8eREua8+Hhe LkQPUdjR6LZjH5o5XVQSXYUPDrHdsNQRCxJvlhZR+PQfT4HcuQhtGKYMq4Pin2QXy7pJ tMVA== X-Gm-Message-State: AOAM531O9ThlWWyvxcvVEkiQ9hw55Qp8QzZ4phl34mGaAxc1sn17O5ij N6POPi72yBh8hTLv8NrZaX4OPegIPOI= X-Google-Smtp-Source: ABdhPJxoDJ6htJO7w0r5lmNzG/guuaZpNEeyLvjrRA7GI/a0ibQIYSvsUgJ9wEDaa265y/pzKwEcpQ== X-Received: by 2002:a1c:cc01:: with SMTP id h1mr17648201wmb.114.1603728558583; Mon, 26 Oct 2020 09:09:18 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t19sm19526065wmj.42.2020.10.26.09.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 09:09:18 -0700 (PDT) Message-Id: <9ffcc5b78e358d0ed4da2c52ba87174dc94e544c.1603728555.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Date: Mon, 26 Oct 2020 16:09:15 +0000 Subject: [PATCH v3 2/2] sideband: report unhandled incomplete sideband messages as bugs Fcc: Sent Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 To: git@vger.kernel.org Cc: Jonathan Tan , Jeff King , Johannes Schindelin , Johannes Schindelin , Johannes Schindelin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin It was pretty tricky to verify that incomplete sideband messages are handled correctly by the `recv_sideband()`/`demultiplex_sideband()` code: they have to be flushed out at the end of the loop in `recv_sideband()`, but the actual flushing is done by the `demultiplex_sideband()` function (which therefore has to know somehow that the loop will be done after it returns). To catch future bugs where incomplete sideband messages might not be shown by mistake, let's catch that condition and report a bug. Signed-off-by: Johannes Schindelin --- pkt-line.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkt-line.c b/pkt-line.c index 844c253ccd..657a702927 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -471,6 +471,9 @@ int recv_sideband(const char *me, int in_stream, int out) write_or_die(out, buf + 1, len - 1); break; default: /* errors: message already written */ + if (scratch.len > 0) + BUG("unhandled incomplete sideband: '%s'", + scratch.buf); return sideband_type; } } -- gitgitgadget