batctl: Refresh patches
[feed/routing.git] / batctl / patches / 0005-batctl-Handle-allocation-error-for-path_buff.patch
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
4
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>
11
12 Origin: upstream, https://git.open-mesh.org/batctl.git/commit/3b52283a5f60d1c6ec11628d031e72f0a28a720f
13
14 diff --git a/sys.c b/sys.c
15 index b52434072b34b949c73de8346f8c2dce615423a4..3047b5f6eebf26290f2d8c4840d52bb1bddc3e3f 100644
16 --- a/sys.c
17 +++ b/sys.c
18 @@ -153,6 +153,11 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
19 }
20
21 path_buff = malloc(PATH_BUFF_LEN);
22 + if (!path_buff) {
23 + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
24 + return EXIT_FAILURE;
25 + }
26 +
27 snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
28
29 if (argc != 1) {
30 @@ -253,6 +258,11 @@ int handle_sys_setting(char *mesh_iface, int setting, int argc, char **argv)
31
32 /* prepare the classic path */
33 path_buff = malloc(PATH_BUFF_LEN);
34 + if (!path_buff) {
35 + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
36 + return EXIT_FAILURE;
37 + }
38 +
39 snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
40
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)
43 }
44
45 path_buff = malloc(PATH_BUFF_LEN);
46 + if (!path_buff) {
47 + fprintf(stderr, "Error - could not allocate path buffer: out of memory ?\n");
48 + return EXIT_FAILURE;
49 + }
50 +
51 snprintf(path_buff, PATH_BUFF_LEN, SYS_BATIF_PATH_FMT, mesh_iface);
52
53 if (argc == 1) {