Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gBhKQ-0007LW-IG for pgsql-hackers@arkaria.postgresql.org; Sun, 14 Oct 2018 14:25:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gBhKO-0002is-H8 for pgsql-hackers@arkaria.postgresql.org; Sun, 14 Oct 2018 14:25:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gBhKO-0002il-4c for pgsql-hackers@lists.postgresql.org; Sun, 14 Oct 2018 14:25:08 +0000 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gBhKG-0003dF-Sv for pgsql-hackers@postgresql.org; Sun, 14 Oct 2018 14:25:07 +0000 Received: by mail-qt1-x82d.google.com with SMTP id l41-v6so18771881qtl.8 for ; Sun, 14 Oct 2018 07:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=t7BAGDFGbT/Qa4RIwL9IAspMHdovRWysrp8ex7widX8=; b=UGI1gHv/JAL4v+JgxiDns8ELMYW9dedf+sE133U67WfmjLsHhWfGOF60Os6nhkmafM DuYqtUdHnjFlTgoz042JWEUGISAXpGKsQkTvEtQRfDWeWndF5tinIkZwwFx+R5oYbw0B mY4cPEdEuXaPzAHRi2TxshCLzvUrCwI09rqRpHmKgDilfvgjqOl395BUsKZj2+V6OM6U pDrSzmznQsW9HrnbwgME8VIpt2BbAwln/v5mekTGl2/G4rxETZlxac+YIo/sH2fnBPr6 Auw4oYXGY7dFsQqcr0g/WJUQqgKFoBxWJXyEec5o24+FrwfpyI+Mtq68DuHPyVwJKfaG biTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=t7BAGDFGbT/Qa4RIwL9IAspMHdovRWysrp8ex7widX8=; b=ZACq2z8MtRDVdmjnNdPw5fSpV3dt/34+2xLVTgVeDG1Nz6Me5iuqTfySOzHOLWCbae /d+qGncxzfGalShx6pN7q22agHBbnSTRx9tdRiAnTS0PrgA0l3UgyMjvG9VQ4D7VZWVA T/Dlc3U3w9nApgkD/3I+SmM4IkuuTk8FmKNqgdKW46eXMutjeGHifSAD9Zj1l0ADbjxO +0coTO8WC0c4HjqIODYaUdqLbcTCCFZMK4bEICLZhBsJ5F8TxhD6NbJ8dkxhQYshBjAO nrdoBR2HxkspzZy9V0Bic6ItTVDEyN62mbTl5BE9GCejLI+qWLdArtCgiDgacfmQyNtW CI6A== X-Gm-Message-State: ABuFfohixQw19Xuw4reGwIWoZFe8PXzOhFIixySJquylVn17JM/aYH94 5tbDpGVnE3J/AzZLxwvarT3736XjvA== X-Google-Smtp-Source: ACcGV63c14tjMuUiupjZfXAkpThlX/Xr7qoc0BqbKY0nZw0kp9Uo7RXRmbSZwV/yakXbSPcXGhuEuQ== X-Received: by 2002:a0c:89c8:: with SMTP id 8mr13535278qvs.240.1539527097657; Sun, 14 Oct 2018 07:24:57 -0700 (PDT) Received: from [192.168.10.146] ([98.122.175.38]) by smtp.gmail.com with ESMTPSA id s71-v6sm5459083qkl.86.2018.10.14.07.24.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Oct 2018 07:24:56 -0700 (PDT) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: pgsql: Add TAP tests for pg_verify_checksums To: Michael Paquier Cc: Michael Banck , Andres Freund , Postgres hackers , Daniel Gustafsson , Magnus Hagander References: <20181012013918.GA30064@paquier.xyz> <20181012015319.ezsb2cxb52ulbqgx@alap3.anarazel.de> <20181012020758.GB30064@paquier.xyz> <20181012024118.q3jwio7gf52nsrmm@alap3.anarazel.de> <20181012031158.GD30064@paquier.xyz> <20181012060543.GE30064@paquier.xyz> <20181012101447.GA13287@nighthawk.caipicrew.dd-dns.de> <20181013083040.GF30064@paquier.xyz> <1bce17ea-08f7-c480-fe69-a5f6467b461f@2ndQuadrant.com> <20181014015902.GI30064@paquier.xyz> Message-ID: Date: Sun, 14 Oct 2018 10:24:55 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20181014015902.GI30064@paquier.xyz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-MW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/13/2018 09:59 PM, Michael Paquier wrote: > On Sat, Oct 13, 2018 at 05:53:00PM -0400, Andrew Dunstan wrote: >> It occurred to me that a pretty simple fix could just be to blacklist >> everything that didn't start with a digit. The whitelist approach is >> probably preferable... depends how urgent we see this as. > Yeah, possibly, still that's not a correct long-term fix. So attached > is what I think we should do for HEAD and REL_11_STABLE with an approach > using a whitelist. I have added positive and negative tests on top of > the existing TAP tests, as suggested by Michael B, and I made the code > use relpath.h to make sure that we don't miss any fork types. > > Any objections to this patch? This code now seems redundant:      if (strcmp(fn, ".") == 0 ||          strcmp(fn, "..") == 0)          return true; I would probably reverse the order of these two tests. It might not make any difference, assuming fn is never an empty string, but it seems more logical to me. +    /* good to go if only digits */ +    if (fn[pos] == '\0') +        return false; +    /* leave if no digits */ +    if (pos == 0) +        return true; It also looks to me like the check for a segment number doesn't ensure there is at least one digit, so "123." might pass, but I could be wrong. In any case, there isn't a test for that, and there probably should be. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services