Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSi8n-0002Sx-Gl for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 16:29:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nSi8l-00043B-CR for pgsql-hackers@arkaria.postgresql.org; Fri, 11 Mar 2022 16:29:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nSi8k-000418-UZ for pgsql-hackers@lists.postgresql.org; Fri, 11 Mar 2022 16:29:19 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nSi8g-00053p-Vg for pgsql-hackers@postgresql.org; Fri, 11 Mar 2022 16:29:17 +0000 Received: by mail-il1-x12e.google.com with SMTP id b14so6317406ilf.6 for ; Fri, 11 Mar 2022 08:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=R62mMtXIwap5Ufh8AwQOlgAY+8x5Y/3W3GkcUFQNzUk=; b=nBB39R1upZSZsImEwNzRiYM4YOrBWq4G/Mr48dsQaHUfo/izqb5FMm3RKCP4BqK1b6 3EaGrzumWmNVYyZNKOfPqKkQTJ546hJIXBGMO1zBayWv96S6gf2RQVau+vmBR1lLT4Jz R9xEEw8S18cmfi2jxX/jldP++jfNLiHHAurQPDXU/WnqAsF+T3QpEcO67KtW1jl/4OLV nY+aiQOOANq4gRWQX1P8U/vLCTJt4PpIUAqHk/J3RmpirY+nvMowxZfDM3ae9203kJWG YaH6eXSQ7kY1Gm6iE/3dmwY+F7h3pTSv5TPMjSMWOvAm9E9BiCp7zNuZVh+EOga++njL o6ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=R62mMtXIwap5Ufh8AwQOlgAY+8x5Y/3W3GkcUFQNzUk=; b=OwWsPramVlxUOrNRJBB8nWUk3qzY5ln0NkHCVn7xp5OKrsZVJZ2+KYGytPMVtYHp21 GJfZb0LmOsSzogfDTsQbYSNAq6rpCGnN26xCx4rgtqC+YcWy7kBIH9WMqW9M7HUxmbW1 VzoRlAjDkInBQQ2VNV9FQHWyYDbd9lRb8gnnq369t4HLbeus6Rk7sZyIG+t/bJ5brFYA FpMky6HMc+AicH84TgAAXfbzpv4i9uzOvN9TWnbTW2jK2pT4KXqLl9W7QXkB4dLENnmY s6F3Ak00t+6rzZiboa+yIJEydidE9eqDJ+m9NxuFzow+RfL639xeHTUgSCyVJ/hfi7uX cDMg== X-Gm-Message-State: AOAM533HApBlxN77mGPdtPTT5xLpPpOgdCos5hWI3vXwZzqhOORzRjBk 2wRynt9vuBjaG1LqI1gr6gCzRg== X-Google-Smtp-Source: ABdhPJypYVLbAcplhqIIfEle1072Il3TP2L7u66/0/+GGhUI78AU+u6maXh54u5CaKTS6umhcD5YMg== X-Received: by 2002:a05:6e02:de2:b0:2c6:f14:884a with SMTP id m2-20020a056e020de200b002c60f14884amr8505212ilj.100.1647016153884; Fri, 11 Mar 2022 08:29:13 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id g8-20020a056602248800b006409fb2cbccsm4295471ioe.32.2022.03.11.08.29.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Mar 2022 08:29:12 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EC420800DCA; Fri, 11 Mar 2022 10:29:11 -0600 (CST) Date: Fri, 11 Mar 2022 10:29:11 -0600 From: Justin Pryzby To: Robert Haas Cc: Jeevan Ladhe , Alvaro Herrera , "Shinoda, Noriyoshi (PN Japan FSIP)" , Dipesh Pandit , Abhijit Menon-Sen , Dmitry Dolgov <9erthalion6@gmail.com>, Jeevan Ladhe , Mark Dilger , pgsql-hackers@postgresql.org, tushar , Andres Freund Subject: Re: refactoring basebackup.c Message-ID: <20220311162911.GM28503@telsasoft.com> References: <20220311010223.GI28503@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Mar 11, 2022 at 10:19:29AM -0500, Robert Haas wrote: > So I think we should just refuse this command. Patch for that attached. Sounds right. Also, I think the magic 8 for .gz should actually be a 7. I'm not sure why it tests for ".gz" but not ".tar.gz", which would help to make them all less magic. commit 1fb1e21ba7a500bb2b85ec3e65f59130fcdb4a7e Author: Justin Pryzby Date: Thu Mar 10 21:22:16 2022 -0600 pg_basebackup: make magic numbers less magic The magic 8 for .gz should actually be a 7. .tar.gz 1234567 .tar.lz4 .tar.zst 12345678 See d45099425, 751b8d23b, 7cf085f07. diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 9f3ecc60fbe..8dd9721323d 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -1223,17 +1223,17 @@ CreateBackupStreamer(char *archive_name, char *spclocation, is_tar = (archive_name_len > 4 && strcmp(archive_name + archive_name_len - 4, ".tar") == 0); - /* Is this a gzip archive? */ - is_tar_gz = (archive_name_len > 8 && - strcmp(archive_name + archive_name_len - 3, ".gz") == 0); + /* Is this a .tar.gz archive? */ + is_tar_gz = (archive_name_len > 7 && + strcmp(archive_name + archive_name_len - 7, ".tar.gz") == 0); - /* Is this a LZ4 archive? */ + /* Is this a .tar.lz4 archive? */ is_tar_lz4 = (archive_name_len > 8 && - strcmp(archive_name + archive_name_len - 4, ".lz4") == 0); + strcmp(archive_name + archive_name_len - 8, ".tar.lz4") == 0); - /* Is this a ZSTD archive? */ + /* Is this a .tar.zst archive? */ is_tar_zstd = (archive_name_len > 8 && - strcmp(archive_name + archive_name_len - 4, ".zst") == 0); + strcmp(archive_name + archive_name_len - 8, ".tar.zst") == 0); /* * We have to parse the archive if (1) we're suppose to extract it, or if