1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
---
kpartx/devmapper.c | 3 ++-
libmultipath/alias.c | 1 +
libmultipath/blacklist.c | 7 +++++++
libmultipath/prioritizers/iet.c | 2 ++
libmultipath/prioritizers/weightedpath.c | 5 ++++-
libmultipath/regex.c | 5 ++++-
libmultipath/sysfs.c | 3 ++-
libmultipath/util.c | 2 +-
8 files changed, 23 insertions(+), 5 deletions(-)
Index: multipath-tools-130222/kpartx/devmapper.c
===================================================================
--- multipath-tools-130222.orig/kpartx/devmapper.c
+++ multipath-tools-130222/kpartx/devmapper.c
@@ -132,8 +132,9 @@ dm_addmap (int task, const char *name, c
goto addout;
r = dm_task_run (dmt);
- addout:
+addout:
dm_task_destroy (dmt);
+ free(prefixed_uuid);
return r;
}
Index: multipath-tools-130222/libmultipath/alias.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/alias.c
+++ multipath-tools-130222/libmultipath/alias.c
@@ -328,6 +328,7 @@ get_user_friendly_alias(char *wwid, char
if (fflush(f) != 0) {
condlog(0, "cannot fflush bindings file stream : %s",
strerror(errno));
+ free(alias);
fclose(f);
return NULL;
}
Index: multipath-tools-130222/libmultipath/blacklist.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/blacklist.c
+++ multipath-tools-130222/libmultipath/blacklist.c
@@ -79,6 +79,8 @@ set_ble_device (vector blist, char * ven
if (regcomp(&ble->vendor_reg, vendor,
REG_EXTENDED|REG_NOSUB)) {
FREE(vendor);
+ if (product)
+ FREE(product);
return 1;
}
ble->vendor = vendor;
@@ -87,6 +89,10 @@ set_ble_device (vector blist, char * ven
if (regcomp(&ble->product_reg, product,
REG_EXTENDED|REG_NOSUB)) {
FREE(product);
+ if (vendor) {
+ ble->vendor = NULL;
+ FREE(vendor);
+ }
return 1;
}
ble->product = product;
@@ -189,6 +195,7 @@ setup_default_blist (struct config * con
STRDUP(hwe->bl_product),
ORIGIN_DEFAULT)) {
FREE(ble);
+ vector_del_slot(conf->blist_device, VECTOR_SIZE(conf->blist_device) - 1);
return 1;
}
}
Index: multipath-tools-130222/libmultipath/prioritizers/iet.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/prioritizers/iet.c
+++ multipath-tools-130222/libmultipath/prioritizers/iet.c
@@ -109,6 +109,7 @@ int iet_prio(const char *dev, char * arg
ssize_t nchars = readlink(path, buffer, sizeof(buffer)-1);
if (nchars != -1) {
char *device;
+ buffer[nchars] = '\0';
device = find_regex(buffer,"(sd[a-z]+)");
// if device parsed is the right one
if (device!=NULL && strncmp(device, dev, strlen(device)) == 0) {
@@ -118,6 +119,7 @@ int iet_prio(const char *dev, char * arg
if (ip!=NULL && strncmp(ip, preferredip, strlen(ip)) == 0) {
// high prio
free(ip);
+ free(device);
closedir(dir_p);
return 20;
}
Index: multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/prioritizers/weightedpath.c
+++ multipath-tools-130222/libmultipath/prioritizers/weightedpath.c
@@ -61,8 +61,10 @@ int prio_path_weight(struct path *pp, ch
regex = get_next_string(&temp, split_char);
/* Return default priority if the argument is not parseable */
- if (!regex)
+ if (!regex) {
+ FREE(arg);
return priority;
+ }
if (!strcmp(regex, HBTL)) {
sprintf(path, "%d:%d:%d:%d", pp->sg_id.host_no,
@@ -72,6 +74,7 @@ int prio_path_weight(struct path *pp, ch
} else {
condlog(0, "%s: %s - Invalid arguments", pp->dev,
pp->prio.name);
+ FREE(arg);
return priority;
}
Index: multipath-tools-130222/libmultipath/regex.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/regex.c
+++ multipath-tools-130222/libmultipath/regex.c
@@ -3936,8 +3936,11 @@ int eflags;
regs.num_regs = nmatch;
regs.start = TALLOC(nmatch, regoff_t);
regs.end = TALLOC(nmatch, regoff_t);
- if (regs.start == NULL || regs.end == NULL)
+ if (regs.start == NULL || regs.end == NULL) {
+ free(regs.start);
+ free(regs.end);
return (int) REG_NOMATCH;
+ }
}
/* Perform the searching operation. */
Index: multipath-tools-130222/libmultipath/sysfs.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/sysfs.c
+++ multipath-tools-130222/libmultipath/sysfs.c
@@ -88,7 +88,8 @@ ssize_t sysfs_attr_get_value(struct udev
} else if (size == value_len) {
condlog(4, "overflow while reading from %s", devpath);
size = 0;
- }
+ } else
+ value[size] = '\0';
close(fd);
return size;
Index: multipath-tools-130222/libmultipath/util.c
===================================================================
--- multipath-tools-130222.orig/libmultipath/util.c
+++ multipath-tools-130222/libmultipath/util.c
@@ -175,7 +175,7 @@ devt2devname (char *devname, int devname
sprintf(block_path,"/sys/dev/block/%u:%u", major, minor);
if (lstat(block_path, &statbuf) == 0) {
if (S_ISLNK(statbuf.st_mode) &&
- readlink(block_path, dev, FILE_NAME_SIZE) > 0) {
+ readlink(block_path, dev, FILE_NAME_SIZE-1) > 0) {
char *p = strrchr(dev, '/');
if (!p) {
|