From patchwork Mon Feb 1 09:56:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans Dedecker X-Patchwork-Id: 576435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6696614031E for ; Mon, 1 Feb 2016 21:06:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=AKzlFvtX; dkim-atps=neutral Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id C58A828C603; Mon, 1 Feb 2016 10:59:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 0E53728BE87 for ; Mon, 1 Feb 2016 10:57:45 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 1 Feb 2016 10:57:44 +0100 (CET) Received: by mail-wm0-f67.google.com with SMTP id 128so8275317wmz.3 for ; Mon, 01 Feb 2016 01:57:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RhSZro58zXwD1hge/sh4r82QiPsbpsnv5We1JOK50xs=; b=AKzlFvtX7WYBwbiMP45EbQ4h1xeS4dCnPVT1rL5NdKA53mVzbq9YDgyow7BIznx5xa vteqVziUlHU6TPyqSpQ5Py2JuPDm/kjWw0cfrKQd8n/pBHcrQkXIXPV3LHRujs8eHw0n kcmEjzrI3q6NLhnCToGLHrkZQUBjApq13+B8D6Gl4yaWN2dsu5WvnVMqnQJ4E99tVN9T 6R2g2A/iVrg423bIbne30R/r7cp/mYVn4/RemEpft9nimDb3I/tWR6EZfQkzUnQLFcwy 1HSvIiHkl+SOma3hfiUEV27S3ENa/53ri+7awmM70ID5NkqMQTNTXIAgmTEQ1fycH3t0 t+KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RhSZro58zXwD1hge/sh4r82QiPsbpsnv5We1JOK50xs=; b=f64KuCsx4dZUBMjrV5b6q0LOFYNuu7jRJZMaaBBByMId4sGC0OUsivKSgvRiS/p86w Z6E5XM6L1xE5zqEqitCE4ZHi+JhxN9Akb1epIDOucRWRUg2xpw9IIxUOy/BCiAElJ3GX FeOlf5YZjFHINMtYZmNZbvqqnDiUaRMR8pYHBO5riYEMCexs3099oNiNTUPOP3mEafrj j/q1OSHPBEmja9e+ghF8oZtBP1MTzjuHSh2FR9IoOrmcPh6X0hWUtXswF3gmh6hy0Slp 2LL0vlQh50cHLEGTcJBPRLHepmIZfaWTYrkF3ZzB+WYBdg2SXcPfCiUQ4hKeaIVWBWUZ t0Ow== X-Gm-Message-State: AG10YOTFcNlRXQlXDnBruUAjt+yQblg9Uvr0JAfdZwmvOX3sohjOZGnyVlD2AmmWUWGIUw== X-Received: by 10.194.95.136 with SMTP id dk8mr23117676wjb.96.1454320662008; Mon, 01 Feb 2016 01:57:42 -0800 (PST) Received: from cplx43.eu.thmulti.com ([141.11.62.7]) by smtp.gmail.com with ESMTPSA id m67sm8118759wma.10.2016.02.01.01.57.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Feb 2016 01:57:41 -0800 (PST) From: Hans Dedecker To: openwrt-devel@lists.openwrt.org Date: Mon, 1 Feb 2016 10:56:26 +0100 Message-Id: <1454320590-20710-12-git-send-email-dedeckeh@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454320590-20710-1-git-send-email-dedeckeh@gmail.com> References: <1454320590-20710-1-git-send-email-dedeckeh@gmail.com> Cc: Hans Dedecker , cyrus@openwrt.org Subject: [OpenWrt-Devel] [PATCH netifd 12/16] proto: Fix possible segfaults X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Hans Dedecker --- proto.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proto.c b/proto.c index b91fcde..45eeb4b 100644 --- a/proto.c +++ b/proto.c @@ -101,6 +101,9 @@ alloc_device_addr(bool v6, bool ext) struct device_addr *addr; addr = calloc(1, sizeof(*addr)); + if (!addr) + return NULL; + addr->flags = v6 ? DEVADDR_INET6 : DEVADDR_INET4; if (ext) addr->flags |= DEVADDR_EXTERNAL; @@ -262,6 +265,9 @@ parse_gateway_option(struct interface *iface, struct blob_attr *attr, bool v6) int af = v6 ? AF_INET6 : AF_INET; route = calloc(1, sizeof(*route)); + if (!route) + return NULL; + if (!inet_pton(af, str, &route->nexthop)) { interface_add_error(iface, "proto", "INVALID_GATEWAY", &str, 1); free(route); @@ -514,6 +520,9 @@ default_proto_attach(const struct proto_handler *h, struct interface_proto_state *proto; proto = calloc(1, sizeof(*proto)); + if (!proto) + return NULL; + proto->free = default_proto_free; proto->cb = no_proto_handler;