Re: Patch: initdb: "'" for QUOTE_PATH (non-windows) - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)
Date
Msg-id CAB7nPqQMHbdgT_5S-3qdO4txmg4MFh9GesXnfAkLwjBumyOk1Q@mail.gmail.com
Whole thread Raw
In response to Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)  (Ryan Murphy <ryanfmurphy@gmail.com>)
Responses Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Thu, Aug 18, 2016 at 11:35 AM, Ryan Murphy <ryanfmurphy@gmail.com> wrote:

Be careful of top-posting, this is not this ML style:
http://www.idallen.com/topposting.html

>> I think that's actually a good thing to forbid.
>
> I think I agree Andres, there are already comments in the appendShellString
> function to this effect - they say that CR/LF chars in a file name are
> mostly used for malicious hacking attempts anyways - I know I've hardly ever
> needed a newline in a file name.
>
> Did you see anything else in my code that you have recommendations about?  I
> made sure to free the PQExpBufferStr vars that I allocated.

+        { /* pg_ctl command w path, properly quoted */
+            PQExpBuffer pg_ctl_path = createPQExpBuffer();
+            printfPQExpBuffer(pg_ctl_path, "%s%spg_ctl",
+                bin_dir,
+                (strlen(bin_dir) > 0) ? DIR_SEP : ""
+            );
+            appendShellString(start_db_cmd, pg_ctl_path->data);
+            destroyPQExpBuffer(pg_ctl_path);
+        }

This is not really project-style to have an independent block. Usually
those are controlled by for, while or if. And you could use the same
PQExpBuffer for everything.
-- 
Michael



pgsql-hackers by date:

Previous
From: Claudio Freire
Date:
Subject: [WIP] [B-Tree] Keep indexes sorted by heap physical location
Next
From: Andres Freund
Date:
Subject: Re: Patch: initdb: "'" for QUOTE_PATH (non-windows)