Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote

From: Srinath Reddy <srinath2133(at)gmail(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: getting "shell command argument contains a newline or carriage return:" error with pg_dumpall when db name have new line in double quote
Date: 2025-03-27 11:33:44
Message-ID: CAFC+b6q_P2GwTjArh9KdxhJvr1=0msPbTVoB-q_5tf4-f4iH4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

./psql postgres

On Thu, Mar 27, 2025 at 4:16 PM Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

> Yes, sorry, I misread the thread. I think we should proceed with options 1
> and 3 i.e. prevent creation of new databases with a CR or LF, and have
> pgdumpall exit with a more useful error message.
>
agreed.

> Your invention of an is_name_contain_lfcr() function is unnecessary - we
> can just use the standard library function strpbrk() to look for a CR or LF.
>
makes sense,but I have a dumb doubt why in appendShellStringNoError() it
still continues even after it found CR or LF? ,AFAIK The reasoning is this
function is designed to silently filter out \n and \r while still producing
a usable shell-safe argument. It informs the caller of the issue (false
return value) but does not abruptly stop execution,then the caller will
decide what to do but every place this function is called they are just
throwing the error.

if we could just break the loop right after we found \n or \r in
appendShellStringNoError() we can also use strpbrk() here and during
creation of new database as you suggested.

thoughts?

May the force be with you,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

postgres=#\q

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2025-03-27 11:37:20 Re: Statistics import and export: difference in statistics of materialized view dumped
Previous Message Nazir Bilal Yavuz 2025-03-27 11:30:48 Re: Draft for basic NUMA observability