Re: C Extension woes

From: Andrew Chernow <ac(at)esilo(dot)com>
To: Tim Hawes <thawes(at)novadine(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: C Extension woes
Date: 2008-08-13 11:19:03
Message-ID: 48A2C327.7060900@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tim Hawes wrote:
>
> text * pl_masterkey(PG_FUNCTION_ARGS)
> {
> 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". Try this instead:

size_t length = e_var != NULL ? strlen(e_var) : 0;

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2008-08-13 11:19:04 Re: Replay attack of query cancel
Previous Message Jan Urbański 2008-08-13 11:18:25 Re: C Extension woes