Re: Reasons not to like asprintf

From: Florian Weimer <fweimer(at)redhat(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Reasons not to like asprintf
Date: 2013-10-23 07:02:30
Message-ID: 52677486.90207@redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/22/2013 11:06 PM, Tom Lane wrote:

> Attached is a draft, which compiles though I've not yet actually tested it.

nprinted = vsnprintf(buf, len, fmt, args);

Assert(buf[len - 1] == '\0');

The assert may fire if len > INT_MAX and the system returns with errno
== EOVERFLOW, as required by POSIX. It's probably better to move it
after the error logging.

--
Florian Weimer / Red Hat Product Security Team

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Samrat Revagade 2013-10-23 09:07:43 Review of pg_rewind
Previous Message Florian Weimer 2013-10-23 06:55:13 Re: Why the asprintf patch is still breaking the buildfarm