From patchwork Mon Jun 27 04:55:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 640786 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rdGpn6yHcz9ssP for ; Mon, 27 Jun 2016 14:55:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=nX/ELdN0; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rdGpn5w8yzDqmF for ; Mon, 27 Jun 2016 14:55:45 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=nX/ELdN0; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Received: from mendozajonas.com (mendozajonas.com [188.166.185.233]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3rdGpj6M8lzDq5f for ; Mon, 27 Jun 2016 14:55:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b=nX/ELdN0; dkim-atps=neutral Received: from skellige.ozlabs.ibm.com (unknown [122.99.82.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: sam@mendozajonas.com) by mendozajonas.com (Postfix) with ESMTPSA id 558CF140055 for ; Mon, 27 Jun 2016 12:55:38 +0800 (SGT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mendozajonas.com; s=mail; t=1467003338; bh=gngqWiGF1Rfb3uqlWMuZQ8/mFjOdsKyECiYCW0+E3c8=; h=From:To:Subject:Date:From; b=nX/ELdN0tW0HuzXxhSjYV83RxZjHbcdANxgEjyHbCXUnRe9TzDEFEx9XiUUiY6BZj glwC1eXHM2S4aRgEuCwy2iFa1R48OL9B5UsNu5HNI5V+xTgb7ubQYMZN9TR1IMqsg7 8j5zTT18F0YfrJzXwRBCATPCrBInQpJyHrL+Cwsg= From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH] lib/pb-config: Properly initialise interface_config Date: Mon, 27 Jun 2016 14:55:31 +1000 Message-Id: <20160627045531.12796-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.9.0 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" The addition of the "url" field is not reflected in config_copy_interface() which leaves the pointer uninitialised, causing a potential segfault later on. Copy the field from the source config, and use talloc_zero() for the interface_config struct to prevent this more generally. Signed-off-by: Samuel Mendoza-Jonas --- lib/pb-config/pb-config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pb-config/pb-config.c b/lib/pb-config/pb-config.c index 8200883..92c7e74 100644 --- a/lib/pb-config/pb-config.c +++ b/lib/pb-config/pb-config.c @@ -10,7 +10,8 @@ static struct interface_config *config_copy_interface(struct config *ctx, struct interface_config *src) { - struct interface_config *dest = talloc(ctx, struct interface_config); + struct interface_config *dest = talloc_zero(ctx, + struct interface_config); memcpy(dest->hwaddr, src->hwaddr, sizeof(src->hwaddr)); dest->ignore = src->ignore; @@ -28,6 +29,8 @@ static struct interface_config *config_copy_interface(struct config *ctx, talloc_strdup(dest, src->static_config.address); dest->static_config.gateway = talloc_strdup(dest, src->static_config.gateway); + dest->static_config.url = + talloc_strdup(dest, src->static_config.url); break; }