From patchwork Thu Apr 29 12:30:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1471684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::140; helo=mail-lf1-x140.google.com; envelope-from=swupdate+bncbd2zdgn6sekrbxgnvkcamgqekfjohaq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=iAXvXScK; dkim-atps=neutral Received: from mail-lf1-x140.google.com (mail-lf1-x140.google.com [IPv6:2a00:1450:4864:20::140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FWFFv0Nzcz9sWc for ; Thu, 29 Apr 2021 22:30:25 +1000 (AEST) Received: by mail-lf1-x140.google.com with SMTP id e29-20020a19691d0000b02901ae573d705fsf14881769lfc.23 for ; Thu, 29 Apr 2021 05:30:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1619699421; cv=pass; d=google.com; s=arc-20160816; b=DAZV1P3moFJ5Y7khXTg8RJSO3Oi78NfF5J+7S8wUr9KCf2KDd/8X9aCqCbsC0Z4h2g hN8jpdJVHyoeLjDFW2FHTH0wdwOXfFUTu69j+si9b4Td5rk+vvUDEskq0CoeMqPq3ywK El/Sa0m17ESrSy+evYOaqeSnZjobvSfCjIrAGAKXS8IhvImOsnrVNivYmCijl5xnUbif Z8dNbiGOlBY79eXTzQFntrdR198VoadpkCp6k0kQ5hgbzSftb0hENA0MXGtbb0uV9xQb Pj9dW5t3L+DwCRuZdaM+VYzL+arEjQykbynIu6DjXb/x+9V1wS13qtTvEBKuAoPo57xf m/XA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=u5md6wberAiz8Ko28Nttd7RYetXElImXDB6YxUsDP5w=; b=sZisXTSoI/KxOewGiSNMQ0GfW5qxG2Aiq0RIXp5O9n5pAiucw/Qi0gyKjKSYmuESTK SyYVss8oNWWvk0Y9HZ8yR+HSbjgIx8fESqyydLGl1kQICV7f6I+Fp1x7aUkHjebRT+fq E374aMGKch4R+qE11uwz6kIFviTcrBbQuWnUrng2Ug+GOBDjpmruVBRSMIXGoSIAhUkm kERAqMYiP4HEiFrpHnLS60KWF3DiIDw30WsIpyXip5xeF1kJxP2KRoiNMr+uZUMX4eUD Sttorubz4mJYHDSC4/dzzls36eyB4r0MFgisiyNWcYtEfBG1KwhWDaB+1uJezndDk9lt rGbw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of stefano.babic@babic.homelinux.org) smtp.mailfrom=stefano.babic@babic.homelinux.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=u5md6wberAiz8Ko28Nttd7RYetXElImXDB6YxUsDP5w=; b=iAXvXScK1F1GpE7ou5M84WpZFuP/YpVlzQpmTLrrjNUALTKRdPRKXNHC7rQVvCJI7A jP0ubv/UitYqvAfkHhx/Ue0cXDwEiONjigI19HrQuXOd+wOoEG38QDfpXJano8c4Z/B5 ml21NaxfNldatX7ppMyqflfujGvOOtL0nZvggR0iDvf5XD9CL6LlEA5v7LpgV463UhLo s1SfHxLyhJlhcZrgbYhcv6mu0BKHBRBAfBq6QP/kw5wpVv9QGUJzom/4GZ/NqfTKNIqy 5xhQcS2HL4aReBM2BvNN0PETg72f9USpISnRpPOeAkqv8E1ykGEhgyw1GjTxXJiaYHgk hNOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=u5md6wberAiz8Ko28Nttd7RYetXElImXDB6YxUsDP5w=; b=ObKc4oDDPNc2gLubAnypZF3HgL1OMKQjH34g+5dlETeeHF0n8jdiy9eMR4N9ouVidJ RIOCpQk/6xPpSNLL5bNUh7DM9+LOqdeHjnpLBDH4vE+v02023NOkvvFeiNaJyPDC+Dib Pp4lzRRK4zbeoUOpqg5AGmBuftd6eQh/yNUZmq7EJUngyYNwykQvILS2kXIozpJkPmZ3 W3Aaifg/oxAmJ8fH3//x/FZ4XbXDMB5JokdruXxz+ejD1/PBwul/KYrdMVXlmI1MfAus ORkmkurET/6jLMthk+DIxmbuNFRTfzIsNR+V9rVUFUhKjXkuE7Tr+FcfRWTyk5aHyS2Y 461A== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM530pBoBuhWWT6gunJzy+wcoTFDxWLMY0vHyW16NnRVVPhocC2SSd iOBszLc49cMWZBj84tSBNbE= X-Google-Smtp-Source: ABdhPJyPhVVtppK9MivgOm2SgzMoaYJs00+PLhVXLh4f9vmM8l8lp+3aKeKbP+Jt7D0kFA//GvH8bw== X-Received: by 2002:a05:6512:22c4:: with SMTP id g4mr24541374lfu.501.1619699420857; Thu, 29 Apr 2021 05:30:20 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a19:f815:: with SMTP id a21ls1384071lff.1.gmail; Thu, 29 Apr 2021 05:30:19 -0700 (PDT) X-Received: by 2002:a05:6512:2394:: with SMTP id c20mr24510422lfv.70.1619699419735; Thu, 29 Apr 2021 05:30:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619699419; cv=none; d=google.com; s=arc-20160816; b=rD+9emNDGyjWh0xVznKYwqutQwo1fTc6XSCVdkgIIwy0HhBadXxrL6KPHlw+rC0RKE V5iyOekesx1HQXpSeqEO2gIJgmZNcvRDd9QLrGA/63jljWF+3oFCrCo82vRZNasVty92 q1hY7yySp/PDfVlulItEI7cm48M5WCAljYopb0GGCQ11eKb+7O21H3OuDzmInjLlHQ5u auezU5kL3+ly+WPRltZsYm19zz7RjumRCz7uTsds/v7DRFkOhDlpX3K6UGWhgW3fXGCK c4aJ8KulXa1XkKOOaSrpsTrL5ExKeM3no4aZNI0LdvkX9ay2MZW7KaHMFcHsMpbpdaJp yxKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=8Jzqc+4+ps3FbPgo2dmPD31cu+FQSY+RCM8s3vNWrzc=; b=M+/SQa5144Ki2asAGBRUI9nEQSDu9CtOHvQVRgts5eoPvzdDFPXp6E252oZ2xyYhqX 7EJr9UD1uh7J/3RjFhY8aZEUNJJUPtWeKuCChiVY2tBnnbSUOxmc0h1qoTaW2/XL65tC CBi0ItkYvZPVcQtVJHcld+XMm8afRmuWaGonZU8n6dBX0fPlMu6GSPPZWUJ+O5W4jIgp qznuN262kGKZRnwX4qLlnE5GDA+QWXWOduTVShBnWEuNjw1xAr/dhweph8XcbRopWpvQ HULeBVU5z91R26BqNDdERFCJ+Vxu4Z6/7rr4NvmM6EKhVTeXUhQXodBR9Yr2FwJvFjmt tpoQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of stefano.babic@babic.homelinux.org) smtp.mailfrom=stefano.babic@babic.homelinux.org Received: from mail-out.m-online.net (mail-out.m-online.net. [2001:a60:0:28:0:1:25:1]) by gmr-mx.google.com with ESMTPS id a10si171473lfs.11.2021.04.29.05.30.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Apr 2021 05:30:19 -0700 (PDT) Received-SPF: neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of stefano.babic@babic.homelinux.org) client-ip=2001:a60:0:28:0:1:25:1; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4FWFFk4rhcz1rxMG for ; Thu, 29 Apr 2021 14:30:18 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4FWFFk4jbmz1rX4b for ; Thu, 29 Apr 2021 14:30:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id OTAO4Ht7erLj for ; Thu, 29 Apr 2021 14:30:17 +0200 (CEST) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS for ; Thu, 29 Apr 2021 14:30:17 +0200 (CEST) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 34C464540CBC; Thu, 29 Apr 2021 14:30:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LWWkQUNZlNUj; Thu, 29 Apr 2021 14:30:13 +0200 (CEST) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.48]) by babic.homelinux.org (Postfix) with ESMTP id B3A1F4540C17; Thu, 29 Apr 2021 14:30:13 +0200 (CEST) From: stefano.babic@babic.homelinux.org To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] Do not register multiple handlers with same name Date: Thu, 29 Apr 2021 14:30:11 +0200 Message-Id: <20210429123011.592198-1-stefano.babic@babic.homelinux.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: stefano.babic@babic.homelinux.org X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 2001:a60:0:28:0:1:25:1 is neither permitted nor denied by best guess record for domain of stefano.babic@babic.homelinux.org) smtp.mailfrom=stefano.babic@babic.homelinux.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: Stefano Babic Each handler must have a unique name. Check and reject registgration of new handlers if they were already registered under the same name. Signed-off-by: Stefano Babic --- core/handler.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/core/handler.c b/core/handler.c index fdf178b..0a713cf 100644 --- a/core/handler.c +++ b/core/handler.c @@ -25,10 +25,20 @@ static unsigned long handler_index = ULONG_MAX; int register_handler(const char *desc, handler installer, HANDLER_MASK mask, void *data) { + int i; - if (nr_installers > MAX_INSTALLER_HANDLER - 1) + if ((nr_installers > MAX_INSTALLER_HANDLER - 1) || !desc) return -1; + /* + * Do not register the same handler twice + */ + for (i = 0; i < nr_installers; i++) { + if ((strlen(desc) == strlen(supported_types[i].desc)) && + strcmp(desc, supported_types[i].desc) == 0) + return -1; + } + strlcpy(supported_types[nr_installers].desc, desc, sizeof(supported_types[nr_installers].desc)); supported_types[nr_installers].installer = installer;