psql Segfaults shortly after doing variable substitution

Поиск
Список
Период
Сортировка
Искать

psql Segfaults shortly after doing variable substitution

От:
"William K. Volkman" <wkvpsql@netshark.com>
Дата:
Noted with versions 7.0.3, 7.1.3, and 7.2.1:

The psql interpreter becomes unstable if variable substitutions
are used.  The debugger GDB was unable to help however mpatrol
reports that the sprintf at mainloop.c:389 is steping one byte
farther than the allocation.

Patch file attached.

Cheers,
William.



--- postgresql-7.1.3/src/bin/psql/mainloop.c~	Mon Mar 26 08:18:51 2001
+++ postgresql-7.1.3/src/bin/psql/mainloop.c	Tue May 28 15:00:12 2002
@@ -379,7 +379,8 @@
 				{
 					out_length = strlen(value);
 
-					new = malloc(len + out_length - (1 + in_length) + 1);
+					/* Allow for 'after' character also 2002-05-27 */
+					new = malloc(len + out_length - (1 + in_length) + 1 + 1);
 					if (!new)
 					{
 						psql_error("out of memory\n");

Re: psql Segfaults shortly after doing variable substitution

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


William K. Volkman wrote:
> Noted with versions 7.0.3, 7.1.3, and 7.2.1:
> 
> The psql interpreter becomes unstable if variable substitutions
> are used.  The debugger GDB was unable to help however mpatrol
> reports that the sprintf at mainloop.c:389 is steping one byte
> farther than the allocation.
> 
> Patch file attached.
> 
> Cheers,
> William.
> 
> 
> 

> --- postgresql-7.1.3/src/bin/psql/mainloop.c~	Mon Mar 26 08:18:51 2001
> +++ postgresql-7.1.3/src/bin/psql/mainloop.c	Tue May 28 15:00:12 2002
> @@ -379,7 +379,8 @@
>  				{
>  					out_length = strlen(value);
>  
> -					new = malloc(len + out_length - (1 + in_length) + 1);
> +					/* Allow for 'after' character also 2002-05-27 */
> +					new = malloc(len + out_length - (1 + in_length) + 1 + 1);
>  					if (!new)
>  					{
>  						psql_error("out of memory\n");

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: psql Segfaults shortly after doing variable substitution

От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:

Patch applied.  Thanks.

---------------------------------------------------------------------------



William K. Volkman wrote:
> Noted with versions 7.0.3, 7.1.3, and 7.2.1:
> 
> The psql interpreter becomes unstable if variable substitutions
> are used.  The debugger GDB was unable to help however mpatrol
> reports that the sprintf at mainloop.c:389 is steping one byte
> farther than the allocation.
> 
> Patch file attached.
> 
> Cheers,
> William.
> 
> 
> 

> --- postgresql-7.1.3/src/bin/psql/mainloop.c~	Mon Mar 26 08:18:51 2001
> +++ postgresql-7.1.3/src/bin/psql/mainloop.c	Tue May 28 15:00:12 2002
> @@ -379,7 +379,8 @@
>  				{
>  					out_length = strlen(value);
>  
> -					new = malloc(len + out_length - (1 + in_length) + 1);
> +					/* Allow for 'after' character also 2002-05-27 */
> +					new = malloc(len + out_length - (1 + in_length) + 1 + 1);
>  					if (!new)
>  					{
>  						psql_error("out of memory\n");

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
FAQ