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 1icCZo-0007rh-1E for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Dec 2019 18:07:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1icCZl-0004Hv-Ti for pgsql-bugs@arkaria.postgresql.org; Tue, 03 Dec 2019 18:07:05 +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 1icCZl-0004Ho-Lk for pgsql-bugs@lists.postgresql.org; Tue, 03 Dec 2019 18:07:05 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1icCZe-0006UR-M3 for pgsql-bugs@lists.postgresql.org; Tue, 03 Dec 2019 18:07:05 +0000 Received: by mail-wm1-x344.google.com with SMTP id p17so4642853wma.1 for ; Tue, 03 Dec 2019 10:06:58 -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=9FCqerNNNUinfNgZpNZ0PJsFxWslmPxF/+H8BGzqXuQ=; b=h7TrSb+NKRfAp/FvkWAcLJ6SW3FOxwsVRKwZsKOV7uo8AcRCoF0uWyGpjwWpt/yK3u Mrlg96iZ5DPRL+HTPn8kv4bIvmQU9FwRwH5xjT5HoqOY9d369qxyfyEpr2aO+97T1jLi fSWwKKYBrhpzmlJjgVCPHb2nAogeoudpiXDTmqQpiO+/8+i3zIpMA1WOFRFnAFb9llB1 L0X60k7Dq5/wXH7PQr9u56ILSZXhOpxEjEB88BvPxf01Eqs2v9baco/KTCRokcM+icsT 6HnGKsOHJYBQRox6EnaGSXStXJEuoeOqXxQP3wvCnxMQQx5XbgvEQVTpZUBrBjsBHA2G WODA== 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=9FCqerNNNUinfNgZpNZ0PJsFxWslmPxF/+H8BGzqXuQ=; b=bsCInzPxkI4pEfV0nLKfoG7pzUYu2fWrwAcUWLjv12OkHOaJBQ/DKxYcYu2KqzeksP 6Fv1xm0Dq515G8AZ+DuoDBhP2kBcjI3KpsPDZzeCccZx1KL5RvdRWx5bpoKkqCrO6bwa lBiiBApgeUV3k17SLdAlvZqQlyzPylgVlYINQA2ZsNWSY8+5myZ8AqUiyjv+h/i0GMko GbsOP219TQrsNy8bHXH/A1OZaIy13QNikQS4aVJy5t4JKp6r0q4jAzepXZ//BqZY7U/R 5UYjeZboqLjx7IiRrhzOHkVqJ9M+wTNE1kBOOj/JWL7HV2VgvuX4IG7vSNiiuvK6kX2n pKUg== X-Gm-Message-State: APjAAAUnfKCpyaxNvLHKnXFPBAgIR/doDaszmJvfK3fYhHjDS4VRSJgE zR8nRFwhPMujDP9apvVGQEwjTGJErPg= X-Google-Smtp-Source: APXvYqzmxu8+aY+QA+fL2sxowWih8WQCRtLFIg/DQDgcSDnDwSQWpxEQXvpc8A0wTFRbjyuSWPkHrw== X-Received: by 2002:a1c:1dc9:: with SMTP id d192mr28265229wmd.92.1575396416272; Tue, 03 Dec 2019 10:06:56 -0800 (PST) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id 2sm4808325wrq.31.2019.12.03.10.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2019 10:06:55 -0800 (PST) Date: Tue, 3 Dec 2019 19:06:53 +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: <20191203180653.dyuopwzpvz2iqz2c@development> References: <16144-a36a5bef7657047d@postgresql.org> <20191202161920.d3k7b6dpqcgl5mst@development> <20191203175211.fllaggkccolrngbi@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20191203175211.fllaggkccolrngbi@development> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Dec 03, 2019 at 06:52:11PM +0100, Tomas Vondra wrote: >On Mon, Dec 02, 2019 at 05:19:20PM +0100, Tomas Vondra wrote: >>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. >> > >I've pushed a fix for this, rejecting maxlen values less than 1. I also >backpatched this to all supported releases (the issue exists since 9.3). > Damn, a silly typo in the commit subject (leat -> least) ... :-/ regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services