From patchwork Thu Jun 28 07:21:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 935967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GWRz1sFJz9ryk for ; Thu, 28 Jun 2018 17:21:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="OgADTgPu"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dQVOTELp"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41GWRz0C1BzF1RJ for ; Thu, 28 Jun 2018 17:21:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="OgADTgPu"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dQVOTELp"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=66.111.4.25; helo=out1-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="OgADTgPu"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dQVOTELp"; dkim-atps=neutral Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41GWRs43j5zF1QP for ; Thu, 28 Jun 2018 17:21:45 +1000 (AEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id DF89E21B25; Thu, 28 Jun 2018 03:21:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 28 Jun 2018 03:21:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=G4NT/cRG84j2za+Su S9balYYIrHJJyIcd61q6QgQP0g=; b=OgADTgPuezfnvgiLM6fd/h439Jj0sr4WA P43uif/D1PMQ/stN0UCDLJ+iepFIGNPR9PnnLBCVUU3mdpqSxVxHyGVQW1gtO02B 0JFyDZaMPqSSWcjM0YMUIe8JNIlHOyMaPbE/qMjSuN/NsYaqJUpDfNbnHW24jTAy MKVb3n3c4AjIbX6d+f5AVKJ/YkfyCyt1ssJaNsTX5NgzXDgTBp5h85M/l1g48nyH lHYV0ZU6VtUJ8f3qhun/ROy5DSHWGvWhETVZEUUErYQIL5sOTuiHaay/5+upEr9O 6eM4IdyoLK7971G90dE28uIBpxZEdTYubGlH2YhIo+10SlkshlerQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=G4NT/cRG84j2za+Su S9balYYIrHJJyIcd61q6QgQP0g=; b=dQVOTELpCZHWE9Y62oUKTx+1WYORYSH67 GIElwECEUQe6ULGZeGU2+0xcBLTytgH/BilkuMvSM8eItg/TcWXFtOUnb9BQTxQ7 PHwjL2VFgjNQ86BLiL2FWv5ppFRqy/IVSq0DVm/Rjw9TrbfC6+nZZJgs9LAg2eqY OCEGFfwQoZ9aEmOyrjqUbO8dfHOaKDHz/PpraaGYu0V+r7Mp+LiZqbEb5iNzMCla yqrHYHfOegR0r3Vlv1wdoJl5xFojDXGs5fWVx38VNxl9YC4e7620C/i5Q/EibTY7 8yXUvEzQqM/Y6q0kxj3DoE+Qw83Hxi3c2RmLw+pujFHr/oe1vUBQg== X-ME-Proxy: X-ME-Sender: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id 67131E47DC; Thu, 28 Jun 2018 03:21:41 -0400 (EDT) From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH] discover/user-event: Check for required parameters Date: Thu, 28 Jun 2018 17:21:35 +1000 Message-Id: <20180628072135.19937-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.18.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Check for some required parameters in the 'dhcp' handler, and in the 'add' handler return an error if parse_user_event() fails rather than charging ahead into a segfault. Signed-off-by: Samuel Mendoza-Jonas --- discover/user-event.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/discover/user-event.c b/discover/user-event.c index 77d28c1..7f63d43 100644 --- a/discover/user-event.c +++ b/discover/user-event.c @@ -390,6 +390,9 @@ static int user_event_dhcp(struct user_event *uev, struct event *event) uint8_t hwaddr[MAC_ADDR_SIZE]; + if (!event_get_param(event, "mac") || !event_get_param(event, "ip")) + return -1; + sscanf(event_get_param(event, "mac"), "%hhX:%hhX:%hhX:%hhX:%hhX:%hhX", hwaddr, hwaddr + 1, hwaddr + 2, @@ -411,6 +414,7 @@ static int user_event_add(struct user_event *uev, struct event *event) struct device_handler *handler = uev->handler; struct discover_context *ctx; struct discover_device *dev; + int rc; /* In case this is a network interface, try to refer to it by UUID */ dev = discover_device_create(handler, event_get_param(event, "mac"), @@ -418,7 +422,11 @@ static int user_event_add(struct user_event *uev, struct event *event) dev->device->id = talloc_strdup(dev, event->device); ctx = device_handler_discover_context_create(handler, dev); - parse_user_event(ctx, event); + rc = parse_user_event(ctx, event); + if (rc) { + pb_log("parse_user_event returned %d\n", rc); + return rc; + } device_handler_discover_context_commit(handler, ctx);