Re: C Extension woes - Mailing list pgsql-hackers

From Tom Lane
Subject Re: C Extension woes
Date
Msg-id 18797.1218638066@sss.pgh.pa.us
Whole thread Raw
In response to Re: C Extension woes  (Andrew Chernow <ac@esilo.com>)
List pgsql-hackers
Andrew Chernow <ac@esilo.com> writes:
> Tim Hawes wrote:
>> char *e_var = getenv("PGMASTERKEY");
>> size_t length = VARSIZE(e_var) - VARHDRSZ;

> The VARSIZE macro is for variable length structures, like a text or 
> bytea which contains a length and data member.  You are using this macro 
> on a regular C string "e_var".

The code on the output side is wrong too: if the useful data length is
"length", then the palloc has to ask for length + VARHDRSZ, and that's
also what's got to be put into the length word.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Magnus Hagander
Date:
Subject: Re: Replay attack of query cancel
Next
From: "Michael Nacos"
Date:
Subject: Re: Overhauling GUCS