Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cHtju-0006Dm-8X for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Dec 2016 14:44:02 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cHtjt-0007wo-Lh for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Dec 2016 14:44:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cHtjt-0007wi-Bd for pgsql-bugs@postgresql.org; Fri, 16 Dec 2016 14:44:01 +0000 Received: from mail-ua0-x22e.google.com ([2607:f8b0:400c:c08::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1cHtjp-0004SW-RE for pgsql-bugs@postgresql.org; Fri, 16 Dec 2016 14:44:00 +0000 Received: by mail-ua0-x22e.google.com with SMTP id 51so39940609uai.1 for ; Fri, 16 Dec 2016 06:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=kQnqk9OZZl0VNXZWboCrCZOiSwkpht+f1Q0vKyakqa8=; b=N6iN5eZ24so4PcDqaYFjag9NZJxX4mldbD7qUyF8CRQXS0TAgj4P0bNEvLVm3tPamC AHemJD14fhW5QAU3+dqE0Hnp5BGYoJfSijxNFR4JGphnswXG0bItGxeosOAQkmBCag5q AjEeiLg4zNpCD0Uu28BvZlCdRjhxV+Zrt2Sy6homK6LsYJd3OBRkz6++XvjFgtrTcuMt aPEX6p3C1pWod08LoaMOT1DWk40L4uxih6kQSiYMtu1HwWtrs663lEnsVi8XI8ZELisC TVWYC+J54IE1zYTQD+J58l7Ieg/Av9/loAurALJuQmWwVhXuQVvGwM73eU3DI7lVKxcE heMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=kQnqk9OZZl0VNXZWboCrCZOiSwkpht+f1Q0vKyakqa8=; b=erHws+1QVZIC/Qbd3W8gB1FcO/Zra6OrGXnDyzCoUiRP6b/ZHOlVp66DsSaGmwTZtU HCdwZLg6rgpJXmzAmlTnDdxcrLptO5dI3ViXm0yxx81Z9ue78IYJ669sZxapj/mGR9Q1 6lb4dIvePmn8hArvuVcjgCSa+nZutw6zQ++MkMI2z/Hq5lWUQ3ostzsd85kpWOs3ZmQW XK5EsT11sF4UyyKeavZ3uZx3qbOZBa8jLSrAiCSub+k0wWMWPXySPimGvKLt7394xO7O j3BdiCbYl0g045JfrnRbDjj4sYihMR5JANyfwWAKYjHBBikpU6uFdbHD5cTQhox6+QGH r7Zg== X-Gm-Message-State: AKaTC03ULxdW7P+rOoN11nB6ckwQ6nw/A8TUGea+HL4ixeYYjwVSQqdvNnfIL+Nxfkx2A0YP X-Received: by 10.176.3.143 with SMTP id 15mr2246723uau.10.1481899435805; Fri, 16 Dec 2016 06:43:55 -0800 (PST) Received: from alvin.alvh.no-ip.org ([186.11.67.69]) by smtp.gmail.com with ESMTPSA id 2sm553073uaq.25.2016.12.16.06.43.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 06:43:55 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 53B18392B; Fri, 16 Dec 2016 11:43:51 -0300 (CLST) Date: Fri, 16 Dec 2016 11:43:51 -0300 From: Alvaro Herrera To: hlinnaka@iki.fi Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14468: One byte buffer overlow in quote_literal_cstr() Message-ID: <20161216144351.apdbuk4je5ywekle@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161216105001.13334.42819@wrigleys.postgresql.org> User-Agent: NeoMutt/20161104 (1.7.1) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org hlinnaka@iki.fi wrote: > Looking at quote_literal_cstr(), it simply doesn't take into account the > space needed for the NULL terminator, when it allocates the buffer. The fix > is a straightforward + 1 to the allocation. I'll go and do that shortly, and > backpatch. Hm, that's a bit confusing. I thought the +3 included the terminator, but what it's actually for is the optional starting E; and the reason quote_literal doesn't need similar patching it is that there is no terminator 'cause it produces varlena. I would think this deserves a comment ... -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs