1 From: Sven Eckelmann <sven.eckelmann@openmesh.com>
2 Date: Thu, 23 Nov 2017 15:04:37 +0100
3 Subject: batctl: Handle allocation error for path_buff
5 Fixes: 5a1af99276b0 ("batctl: adapt batctl to new sysfs interface handling")
6 Fixes: 306fcb4480c9 ("batctl: support for multiple mesh clouds")
7 Fixes: af115c9acf44 ("batctl: support new gateway sysfs API")
8 Fixes: 2c2cb260ad2e ("batctl: list supported and configured routing algorithms")
9 Signed-off-by: Sven Eckelmann <sven.eckelmann@openmesh.com>
10 Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
12 Origin: upstream, https://git.open-mesh.org/batctl.git/commit/3b52283a5f60d1c6ec11628d031e72f0a28a720f
14 diff --git a/sys.c b/sys.c
15 index b52434072b34b949c73de8346f8c2dce615423a4..3047b5f6eebf26290f2d8c4840d52bb1bddc3e3f 100644
18 @@ -153,6 +153,11 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
21 path_buff = malloc(PATH_BUFF_LEN);
23 + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
24 + return EXIT_FAILURE;
27 snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
30 @@ -253,6 +258,11 @@ int handle_sys_setting(char *mesh_iface, int setting, int argc, char **argv)
32 /* prepare the classic path */
33 path_buff = malloc(PATH_BUFF_LEN);
35 + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
36 + return EXIT_FAILURE;
39 snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
41 /* if the specified interface is a VLAN then change the path to point
42 @@ -325,6 +335,11 @@ int handle_gw_setting(char *mesh_iface, int argc, char **argv)
45 path_buff = malloc(PATH_BUFF_LEN);
47 + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
48 + return EXIT_FAILURE;
51 snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);