Bug #737: PQescapeBytea parameter #3 size_t *to_length

Started by PostgreSQL Bugs Listover 23 years ago3 messagesbugs
Jump to latest
#1PostgreSQL Bugs List
pgsql-bugs@postgresql.org

Christoph Haller (ch@rodos.fzk.de) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
PQescapeBytea parameter #3 size_t *to_length

Long Description
Hi,

I am referring to

PostgreSQL 7.2.1 Documentation
Chapter 1. libpq - C Library
1.3. Command Execution Functions
1.3.3. Escaping binary strings for inclusion in SQL queries

I found the line
"The result string length does not include the terminating zero byte of the result."
is not right.
The result string length does indeed include the terminating zero byte.

When I do

binarystr = (char *)
PQescapeBytea((unsigned char *)"\01\02",2,(size_t *)&binarylen);
printf(" binarylen = %d \n", binarylen) ;

I'll get
binarylen = 3

I also dropped a DocNote, but unfortunately there is no way to
scroll on longer notes. Maybe you like to fix this, too.

Regards, Christoph

Sample Code

No file was uploaded with this report

#2Bruce Momjian
bruce@momjian.us
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #737: PQescapeBytea parameter #3 size_t *to_length

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.

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

pgsql-bugs@postgresql.org wrote:

Christoph Haller (ch@rodos.fzk.de) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
PQescapeBytea parameter #3 size_t *to_length

Long Description
Hi,

I am referring to

PostgreSQL 7.2.1 Documentation
Chapter 1. libpq - C Library
1.3. Command Execution Functions
1.3.3. Escaping binary strings for inclusion in SQL queries

I found the line
"The result string length does not include the terminating zero byte of the result."
is not right.
The result string length does indeed include the terminating zero byte.

When I do

binarystr = (char *)
PQescapeBytea((unsigned char *)"\01\02",2,(size_t *)&binarylen);
printf(" binarylen = %d \n", binarylen) ;

I'll get
binarylen = 3

I also dropped a DocNote, but unfortunately there is no way to
scroll on longer notes. Maybe you like to fix this, too.

Regards, Christoph

Sample Code

No file was uploaded with this report

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Bruce Momjian
bruce@momjian.us
In reply to: PostgreSQL Bugs List (#1)
Re: Bug #737: PQescapeBytea parameter #3 size_t *to_length

Doc change made. Thanks.

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

pgsql-bugs@postgresql.org wrote:

Christoph Haller (ch@rodos.fzk.de) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
PQescapeBytea parameter #3 size_t *to_length

Long Description
Hi,

I am referring to

PostgreSQL 7.2.1 Documentation
Chapter 1. libpq - C Library
1.3. Command Execution Functions
1.3.3. Escaping binary strings for inclusion in SQL queries

I found the line
"The result string length does not include the terminating zero byte of the result."
is not right.
The result string length does indeed include the terminating zero byte.

When I do

binarystr = (char *)
PQescapeBytea((unsigned char *)"\01\02",2,(size_t *)&binarylen);
printf(" binarylen = %d \n", binarylen) ;

I'll get
binarylen = 3

I also dropped a DocNote, but unfortunately there is no way to
scroll on longer notes. Maybe you like to fix this, too.

Regards, Christoph

Sample Code

No file was uploaded with this report

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073