From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id AF8FC6DE208C for ; Tue, 21 Feb 2017 17:05:50 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id T9b41Wynk1_9 for ; Tue, 21 Feb 2017 17:05:48 -0800 (PST) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id B3E086DE2083 for ; Tue, 21 Feb 2017 17:05:48 -0800 (PST) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cgLMi-00024c-CU; Tue, 21 Feb 2017 20:05:08 -0500 Received: (nullmailer pid 27090 invoked by uid 1000); Wed, 22 Feb 2017 01:05:44 -0000 From: David Bremner To: Tomi Ollila , notmuch@notmuchmail.org Subject: Re: read after free in notmuch new In-Reply-To: References: <87efyu6zdg.fsf@tethera.net> <87bmty6vwu.fsf@tethera.net> <87d1ec5ki4.fsf@tethera.net> Date: Tue, 21 Feb 2017 21:05:44 -0400 Message-ID: <87shn73uhj.fsf@tethera.net> MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Feb 2017 01:05:50 -0000 Tomi Ollila writes: > To me it looks like replacing g_hash_table_insert() with > g_hash_table_replace() would do the trick. > > (or even g_hash_table_add()!) > > One has to read the documentation a bit (and compare the docstrings of > these 2 functions to guess the missing pieces) to get some understanding to > this... > Hi Tomi; Thanks for the suggestion. Unfortunately in my experiments it just shifts the invalid memory access to a different piece of memory. I think the problem is that a pointer to the previous copy of that key also leaked a reference via last_ref, so when we kill that via g_hash_table_replace it causes the same problem. d