Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iboQ5-0005ya-3g for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Dec 2019 16:19:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iboQ3-00074k-D6 for pgsql-bugs@arkaria.postgresql.org; Mon, 02 Dec 2019 16:19:27 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iboQ3-00074d-50 for pgsql-bugs@lists.postgresql.org; Mon, 02 Dec 2019 16:19:27 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iboQ0-00029n-1z for pgsql-bugs@lists.postgresql.org; Mon, 02 Dec 2019 16:19:26 +0000 Received: by mail-wr1-x442.google.com with SMTP id q10so8880498wrm.11 for ; Mon, 02 Dec 2019 08:19:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8DzxGNExoyltIVzyXHB8QB/19K/Z+c8TtObZhvVy41c=; b=JewmeTDdCHGXjFpHsApM42I/gL5Kz6saS8C7f+gupCcNeU88Y7NzflYx8w5S6fwMnp ltKJj0dWxKWf94HBmqRsQVa5EhcfDvdlQHeM0UBpvLQQYb6feZLAeb/b+YBUKwwdhG5I 2r7WUfpu5Yti2fpuknZF6vrAnKO3HjLFis4LTqEy+CIU8zWyzn+XrTRNCx5SePwUr+/a LfmEYuSOEE1LM44aiMZM4uzkk3LXvBUH0Ktr+rseT9JJRx0XqmuPsG5CnQxc4VrVZV36 LLpsnY3Y3PLRbh3Bv1M2ITudttzQpt/ft/aYkUoDFwS8fTGFgMwNAAWr0jR1GlpWIe1F S4Gw== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8DzxGNExoyltIVzyXHB8QB/19K/Z+c8TtObZhvVy41c=; b=N1+9E3HaL9JU/SmJzyJaJJLyNZcLcFUJx6sjZkKLIQRq8N1tf51OoSxPZ9aJjI6sVt N+/OtAGHAP8xzcewqGeyQr3SZV6ncJyrFllJFv/5XPUSC9ok6hORtAg7rD+KwGjOUUHw ebBZEfT/wgpuc6fxjt/S23Xl2Xc2QsfD1b8VVd5bO2sfYw6tJKxNIBIgFbzdh/5yZ4g3 cRSynmIqM7EQCw2Oy8LGlLDeL2Fndn3AXzQt3tzhz3usGZsAaHPIrtkleBJaVOhyDOaH eaKewGaTLJyjL8LK/RAuAUK34mMK5iJw11Je/IZD8pBxXawgUz65l+MsVZkZfU/uUQ4O d68w== X-Gm-Message-State: APjAAAUHX2x4iDWM5/ZF6UgIPJAbdCy+GRHEr6NGEs+0OWdXRIxOqXMF x0O/anYrVm12/m4s0V0VHTWiMA== X-Google-Smtp-Source: APXvYqzawvR85Lz5NP8sWA1bCyQ+ppdHm/0Ypdk9z8GOM4nnCxCqq+Cs9oeD1FRzgyW35b2X64RHjA== X-Received: by 2002:adf:81e3:: with SMTP id 90mr26983476wra.23.1575303562195; Mon, 02 Dec 2019 08:19:22 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id 2sm40652350wrq.31.2019.12.02.08.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 08:19:21 -0800 (PST) Date: Mon, 2 Dec 2019 17:19:20 +0100 From: Tomas Vondra To: cilizili@protonmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16144: Segmentation fault on dict_int extension Message-ID: <20191202161920.d3k7b6dpqcgl5mst@development> References: <16144-a36a5bef7657047d@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <16144-a36a5bef7657047d@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Dec 02, 2019 at 12:41:21PM +0000, PG Bug reporting form wrote: >The following bug has been logged on the website: > >Bug reference: 16144 >Logged by: cili >Email address: cilizili@protonmail.com >PostgreSQL version: 12.1 >Operating system: CentOS 7.4 >Description: > >The dict_int extension is an example of an add-on dictionary template for >full-text search. The 'intdict' is a built-in dictionary. If we set MAXLEN >parameter with negative value for the dictionary, ts_lexize function causes >a segmentation fault. The negative limit for MAXLEN which causes >segmentation fault is environment dependent. > ># initdb ># pg_ctl -D /var/lib/pgsql/data -l logfile start ># psql > >postgres=# CREATE EXTENSION dict_int; >CREATE EXTENSION >postgres=# ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = -214783648); >ALTER TEXT SEARCH DICTIONARY >postgres=# select ts_lexize('intdict', '12345678'); >server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. >The connection to the server was lost. Attempting reset: Failed. >!> >!>\q > Yeah, this seems to be a failure in evaluating maxlen parameter. It's set to 6 by default, but we simply trust whatever value the user gives us, and then we do this txt[d->maxlen] = '\0'; which fails for obvious reasons. Will fix by rejecting maxlen values less than 1. The docs don't say which value should the the minimum, but 0 seems useless. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services