Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C7D5619713C6; Tue, 6 Dec 2011 12:08:17 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RXxYx-0005D3-Ef; Tue, 06 Dec 2011 16:08:17 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pB6G7vbR021565; Tue, 6 Dec 2011 11:07:57 -0500 (EST) To: Magnus Hagander cc: Andrew Dunstan , Bruce Momjian , PostgreSQL-documentation , PostgreSQL-development Subject: Re: [HACKERS] Moving tablespaces In-reply-to: References: <201112041612.pB4GCHt06225@momjian.us> <23636.1323016890@sss.pgh.pa.us> <4EDBA60D.2050904@dunslane.net> <26148.1323018451@sss.pgh.pa.us> <19894.1323184352@sss.pgh.pa.us> <20005.1323184633@sss.pgh.pa.us> Comments: In-reply-to Magnus Hagander message dated "Tue, 06 Dec 2011 16:39:51 +0100" Date: Tue, 06 Dec 2011 11:07:56 -0500 Message-ID: <21564.1323187676@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201112/22 X-Sequence-Number: 7129 Magnus Hagander writes: > There is some nice precedent in the CREATE TABLESPACE command (though > dependent on HAVE_SYMLINK and not HAVE_READLINK), so I'm just going to > copy the error message from there. Fair enough. Looking at the existing readlink use in port/exec.c, it strikes me that another thing you'd better do is include a check for buffer overrun, ie the test needs to be more like rllen = readlink(fname, link_buf, sizeof(link_buf)); if (rllen < 0 || rllen >= sizeof(link_buf)) ... fail ... Also, you're assuming that the result is already null-terminated, which is incorrect. regards, tom lane