From patchwork Thu Nov 23 14:04:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17154 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 29B2980676; Thu, 23 Nov 2017 15:05:26 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=openmesh-com.20150623.gappssmtp.com header.i=@openmesh-com.20150623.gappssmtp.com header.b="zgIUnz69"; dkim-atps=neutral Received-SPF: None (mailfrom) identity=mailfrom; client-ip=2607:f8b0:400d:c09::241; helo=mail-qk0-x241.google.com; envelope-from=sven.eckelmann@openmesh.com; receiver= Received: from mail-qk0-x241.google.com (mail-qk0-x241.google.com [IPv6:2607:f8b0:400d:c09::241]) by open-mesh.org (Postfix) with ESMTPS id 099C880478 for ; Thu, 23 Nov 2017 15:05:13 +0100 (CET) Received: by mail-qk0-x241.google.com with SMTP id p19so21091173qke.2 for ; Thu, 23 Nov 2017 06:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openmesh-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AtsGYxTBXyS2RaBNpMD5RIHYVewz9+JGvLI0TyqzOHc=; b=zgIUnz69SOmZe+EYWGiDn1Gm4XXmRP0Z3dCEGPCUsyDDApi+lZKPr0xmPC84bRKA0C L3jqklKgdz8Qizndp0fgHfEI6ebzXvn+tEh5kNHA9J1qlANeNPTXwof74uE1h2L4fHPD 5GUh9q6Rr/U1w90MchnLMihrpzBHKrAwbk9v53/d4MK6zr1ClydUzr3yvFG0Manx7CV8 gCTYmdq1JL9wg7mVLlTRVVbVp+KkoPJmaOUZLfVvywe0Eo4QvS2LtnJm+hyQ3n0kof5E L9MxjifucMHBkR7SFWWomLCr6+5bZhZ5gDrN3Lapn6OKm4pHRMB61SsPnUB0sJe7xPkR OeQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AtsGYxTBXyS2RaBNpMD5RIHYVewz9+JGvLI0TyqzOHc=; b=DVQtfNYjV28ixsHiPQ9zSXjMk6mwtmfeANzUyqV4jkul8qeYdeBFnRpttooRIakLc1 W2xmUMpG601lugRZwLfikW5joFzBds3sT2DVRABjO3c8e923RkvyP1CpttgYoAjRJnrY mZEHeJam+TbFTbaAg79uRUaw0KYKdpqHO5xGxGrL168a4WHiIwBjTzluBqbf/PGFpkKV Zevqak+gnQcGldCoYYUi8bqRmVleRlmGsW7l0EhkY/WUikz1AtyWpUeTb50qb2YOwPEa iseFs2TmUpkjDwZHXtHRXb5Mu09tQrPfOp6MsHpXXbhvFrFcG53cJBZeQDK2YIMirbj4 albQ== X-Gm-Message-State: AJaThX43CXGxC8Z48hJ/RNEjqXeM/Ns43QfW+uIKCq8AwMEbyluPAuy3 RJ1d6GnYkwFzfryKRRKD1wzlTZt6 X-Google-Smtp-Source: AGs4zMYbBX/gpvy9l3++A2BnI2GgUZM+mBKdSXIhsoKaea8wJhoCO/6TvXL13jCDa5CDdh/GhB679A== X-Received: by 10.55.174.134 with SMTP id x128mr38386064qke.28.1511445911730; Thu, 23 Nov 2017 06:05:11 -0800 (PST) Received: from sven-desktop.home.narfation.org (p2003007C6F53F7FA6FAE965552C91071.dip0.t-ipconnect.de. [2003:7c:6f53:f7fa:6fae:9655:52c9:1071]) by smtp.gmail.com with ESMTPSA id r22sm12954404qtc.71.2017.11.23.06.05.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Nov 2017 06:05:11 -0800 (PST) From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Thu, 23 Nov 2017 15:04:37 +0100 Message-Id: <20171123140444.17119-4-sven.eckelmann@openmesh.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123140444.17119-1-sven.eckelmann@openmesh.com> References: <20171123140444.17119-1-sven.eckelmann@openmesh.com> Subject: [B.A.T.M.A.N.] [PATCH 03/10] batctl: Handle allocation error for path_buff X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Cc: Sven Eckelmann Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" Fixes: 5a1af99276b0 ("batctl: adapt batctl to new sysfs interface handling") Fixes: 306fcb4480c9 ("batctl: support for multiple mesh clouds") Fixes: af115c9acf44 ("batctl: support new gateway sysfs API") Fixes: 2c2cb260ad2e ("batctl: list supported and configured routing algorithms") Signed-off-by: Sven Eckelmann --- sys.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sys.c b/sys.c index 65b438c..c49b428 100644 --- a/sys.c +++ b/sys.c @@ -153,6 +153,11 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv) } path_buff = malloc(PATH_BUFF_LEN); + if (!path_buff) { + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n"); + return EXIT_FAILURE; + } + snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface); if (argc != 1) { @@ -255,6 +260,11 @@ int handle_sys_setting(char *mesh_iface, int setting, int argc, char **argv) /* prepare the classic path */ path_buff = malloc(PATH_BUFF_LEN); + if (!path_buff) { + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n"); + return EXIT_FAILURE; + } + snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface); /* if the specified interface is a VLAN then change the path to point @@ -329,6 +339,11 @@ int handle_gw_setting(char *mesh_iface, int argc, char **argv) } path_buff = malloc(PATH_BUFF_LEN); + if (!path_buff) { + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n"); + return EXIT_FAILURE; + } + snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface); if (argc == 1) {