Re: appendStringInfoString() micro-opt

From: Neil Conway <neilc(at)samurai(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: appendStringInfoString() micro-opt
Date: 2004-01-31 05:10:47
Message-ID: 87hdyc4sa0.fsf@mailbox.samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Neil Conway <neilc(at)samurai(dot)com> writes:
> I'll put this on the back-burner for now, and repost a complete
> patch later if I get around to it.

I've applied the following patch (since I'd already gone ahead and
done the work) that replaces appendStringInfo(buf, "%s", str) with
appendStringInfoString(buf, str)

It occurred to me that there is a potential security problem with code
like:

char *my_str;
my_str = read_from_an_untrusted_source();
appendStringInfo(buf, my_str);

If my_str contains any formatting characters, this crashes the
backend. I'm not sure if there are any actual exploitable instances of
this in the backend, but the above unsafe coding practise is fairly
common.

-Neil

Attachment Content-Type Size
append-string-opt-4.patch text/x-patch 11.0 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-01-31 05:42:19 Re: appendStringInfoString() micro-opt
Previous Message Tom Lane 2004-01-31 04:36:37 Re: [PATCHES] v7.4.1 text_position() patch