From: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> |
---|---|
To: | Junwang Zhao <zhjwpku(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: [PATCH v1] strengthen backup history filename check |
Date: | 2022-07-25 11:39:48 |
Message-ID: | CALj2ACW78g2hysPgt+eKA-ud0+L49dyZdVTEdqAiKgf6BvNf+g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Jul 25, 2022 at 5:01 PM Junwang Zhao <zhjwpku(at)gmail(dot)com> wrote:
>
> This patch makes the backup history filename check more tight.
Can you please elaborate a bit on the issue with existing
IsBackupHistoryFileName(), if there's any?
Also, the patch does have hard coded numbers [1] which isn't good from
a readability perspective, adding macros and/or comments would help
here.
[1]
static inline bool
IsBackupHistoryFileName(const char *fname)
{
- return (strlen(fname) > XLOG_FNAME_LEN &&
+ return (strlen(fname) == XLOG_FNAME_LEN + 9 + strlen(".backup") &&
strspn(fname, "0123456789ABCDEF") == XLOG_FNAME_LEN &&
- strcmp(fname + strlen(fname) - strlen(".backup"), ".backup") == 0);
+ strspn(fname + XLOG_FNAME_LEN + 1, "0123456789ABCDEF") == 8 &&
+ strcmp(fname + XLOG_FNAME_LEN + 9, ".backup") == 0);
}
Regards,
Bharath Rupireddy.
From | Date | Subject | |
---|---|---|---|
Next Message | Japin Li | 2022-07-25 12:04:30 | Re: Typo in misc_sanity.sql? |
Previous Message | Tom Lane | 2022-07-25 11:39:00 | Re: Typo in misc_sanity.sql? |