Thread: pgsql: Fix fat fingering in 22cb6d28950

pgsql: Fix fat fingering in 22cb6d28950

From
Andrew Dunstan
Date:
Fix fat fingering in 22cb6d28950

Per Rainier Vilela

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/39729ec01d25dbe12e0dd8322c68f242650235c9

Modified Files
--------------
src/bin/pg_dump/pg_restore.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)


Re: pgsql: Fix fat fingering in 22cb6d28950

From
Mahendra Singh Thalor
Date:
On Fri, 11 Apr 2025 at 04:38, Andrew Dunstan <andrew@dunslane.net> wrote:
>
> Fix fat fingering in 22cb6d28950
>
> Per Rainier Vilela
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/39729ec01d25dbe12e0dd8322c68f242650235c9
>
> Modified Files
> --------------
> src/bin/pg_dump/pg_restore.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

Hi,
This seems not a proper fix, rather this is adding a segfault.

Program received signal SIGABRT, Aborted.
0x0000153dc3002acf in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x0000153dc3002acf in raise () from /lib64/libc.so.6
#1  0x0000153dc2fd5ea5 in abort () from /lib64/libc.so.6
#2  0x0000153dc3043cc7 in __libc_message () from /lib64/libc.so.6
#3  0x0000153dc304afcc in malloc_printerr () from /lib64/libc.so.6
#4  0x0000153dc304d050 in _int_free () from /lib64/libc.so.6
#5  0x0000000000426b74 in pg_free (ptr=0x7fff48145ac0) at fe_memutils.c:107
#6  0x0000000000426bef in pfree (pointer=0x7fff48145ac0) at fe_memutils.c:135
#7  0x000000000042354f in destroyStringInfo (str=0x7fff48145ac0) at stringinfo.c:415
#8  0x00000000004055c6 in read_one_statement (inBuf=0x7fff48145b30, pfile=0x1165ec0) at pg_restore.c:909
#9  0x0000000000406339 in process_global_sql_commands (conn=0x115c9d0, dumpdirpath=0x7fff481491d3 "x1", outfile=0x0) at pg_restore.c:1321
#10 0x0000000000405d43 in restore_all_databases (conn=0x115c9d0, dumpdirpath=0x7fff481491d3 "x1", db_exclude_patterns=..., opts=0x115c750, numWorkers=10) at pg_restore.c:1154
#11 0x0000000000404925 in main (argc=7, argv=0x7fff48147448) at pg_restore.c:555

* To destroy a StringInfo, pfree() the data buffer, and then pfree() the
 * StringInfoData if it was palloc'd.  For StringInfos created with
 * makeStringInfo(), destroyStringInfo() is provided for this purpose.
 * However, if the StringInfo was initialized using initReadOnlyStringInfo()
 * then the caller will need to consider if it is safe to pfree the data
 * buffer.

Here, we are passing &q, but we can't free this by destroyStringInfo(&q); 

Fix: pg_free(q.data)

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

Re: pgsql: Fix fat fingering in 22cb6d28950

From
Andrew Dunstan
Date:


On 2025-04-11 Fr 3:24 PM, Mahendra Singh Thalor wrote:
On Fri, 11 Apr 2025 at 04:38, Andrew Dunstan <andrew@dunslane.net> wrote:
>
> Fix fat fingering in 22cb6d28950
>
> Per Rainier Vilela
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/39729ec01d25dbe12e0dd8322c68f242650235c9
>
> Modified Files
> --------------
> src/bin/pg_dump/pg_restore.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>

Hi,
This seems not a proper fix, rather this is adding a segfault.

[...]

Here, we are passing &q, but we can't free this by destroyStringInfo(&q); 

Fix: pg_free(q.data)



Quite right. Clearly I was not having a good day on Thursday. Will fix.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com