From patchwork Thu Oct 20 14:19:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 684632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t09t669RHz9sD5 for ; Fri, 21 Oct 2016 01:19:26 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=JY+KaGQQ; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=I6/orvYoO7JHNg00miA4Y0HGmG8qRerB+T8LcJg6XoG1GWija5eEY VciGfuA/jdYcAQWtXzTwba+cVhyac5Iw/4D7xm49SgKZbaz2uWGrlWyHMdsrE8wI MNHKsdGAIjtP5f62FiWSS5iCfgxi0AYKAPkTgmJC53Xl449E/9+Xgs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=nXbGhIHNLcOLr3TDIXXm0MfM8J0=; b=JY+KaGQQ3rn6PGJWHPdj T7whT1akwfzvp6hdeaXKVrV1+7oy4uaynUgUhh/7B/ujtOw2isC3dS/r0Y/w4z4G LgpfV7wXfY26doreoJz6I4CQdHgh+ISuk8YD1iolTTxujd/XBpJzs0ndQSx9nN2h vUonoAEx5tRtwaArpTVEJHk= Received: (qmail 50728 invoked by alias); 20 Oct 2016 14:19:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 50714 invoked by uid 89); 20 Oct 2016 14:19:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Produce X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Oct 2016 14:19:15 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA11B600D for ; Thu, 20 Oct 2016 14:19:14 +0000 (UTC) Received: from littlehelper.redhat.com (vpn1-6-54.ams2.redhat.com [10.36.6.54]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9KEJCfZ024085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 20 Oct 2016 10:19:14 -0400 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: RFA: Fail gracefully when registering info for an unknown plugin Date: Thu, 20 Oct 2016 15:19:12 +0100 Message-ID: <874m47nlwf.fsf@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes Hi Guys, Whilst experimenting with writing a plugin for gcc I discovered that I could cause a segfault if I attempted to register a PLUGIN_INFO callback with any name other than the name of the plugin. The attached patch fixes this problem and produces an error message instead. OK to apply ? Cheers Nick gcc/ChangeLog 2016-10-20 Nick Clifton * plugin.c (register_plugin_info): Produce an error message if the plugin is not found in the hash table. Index: gcc/plugin.c =================================================================== --- gcc/plugin.c (revision 241361) +++ gcc/plugin.c (working copy) @@ -330,7 +330,15 @@ register_plugin_info (const char* name, struct plugin_info *info) { void **slot = htab_find_slot (plugin_name_args_tab, name, NO_INSERT); - struct plugin_name_args *plugin = (struct plugin_name_args *) *slot; + struct plugin_name_args *plugin; + + if (slot == NULL) + { + error ("unable to register info for plugin '%s' - plugin name not found", + name); + return; + } + plugin = (struct plugin_name_args *) *slot; plugin->version = info->version; plugin->help = info->help; }