|
|
4728c8 |
---
|
|
|
4728c8 |
libmultipath/dmparser.c | 6 ++++--
|
|
|
4728c8 |
libmultipath/regex.c | 9 ++++++++-
|
|
|
4728c8 |
multipath/main.c | 9 ++++++---
|
|
|
4728c8 |
multipathd/cli_handlers.c | 41 ++++++++++++-----------------------------
|
|
|
4728c8 |
multipathd/uxlsnr.c | 13 ++++++++++++-
|
|
|
4728c8 |
5 files changed, 42 insertions(+), 36 deletions(-)
|
|
|
4728c8 |
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/dmparser.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/dmparser.c
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/dmparser.c
|
|
|
4728c8 |
@@ -20,14 +20,16 @@
|
|
|
4728c8 |
static int
|
|
|
4728c8 |
merge_words (char ** dst, char * word, int space)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- char * p;
|
|
|
4728c8 |
+ char * p = *dst;
|
|
|
4728c8 |
int len;
|
|
|
4728c8 |
|
|
|
4728c8 |
len = strlen(*dst) + strlen(word) + space;
|
|
|
4728c8 |
*dst = REALLOC(*dst, len + 1);
|
|
|
4728c8 |
|
|
|
4728c8 |
- if (!*dst)
|
|
|
4728c8 |
+ if (!*dst) {
|
|
|
4728c8 |
+ free(p);
|
|
|
4728c8 |
return 1;
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
|
|
|
4728c8 |
p = *dst;
|
|
|
4728c8 |
|
|
|
4728c8 |
Index: multipath-tools-130222/libmultipath/regex.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/libmultipath/regex.c
|
|
|
4728c8 |
+++ multipath-tools-130222/libmultipath/regex.c
|
|
|
4728c8 |
@@ -123,7 +123,14 @@ static void init_syntax_once(void)
|
|
|
4728c8 |
|
|
|
4728c8 |
/* (Re)Allocate N items of type T using malloc, or fail. */
|
|
|
4728c8 |
#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
|
|
|
4728c8 |
-#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
|
|
|
4728c8 |
+#define RETALLOC(addr, n, t) \
|
|
|
4728c8 |
+do { \
|
|
|
4728c8 |
+ t *tmp = (t *) realloc (addr, (n) * sizeof (t)); \
|
|
|
4728c8 |
+ if (!tmp) \
|
|
|
4728c8 |
+ free(addr); \
|
|
|
4728c8 |
+ (addr) = tmp; \
|
|
|
4728c8 |
+} while(0)
|
|
|
4728c8 |
+
|
|
|
4728c8 |
#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
|
|
|
4728c8 |
|
|
|
4728c8 |
#define BYTEWIDTH 8 /* In bits. */
|
|
|
4728c8 |
Index: multipath-tools-130222/multipath/main.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipath/main.c
|
|
|
4728c8 |
+++ multipath-tools-130222/multipath/main.c
|
|
|
4728c8 |
@@ -394,7 +394,7 @@ out:
|
|
|
4728c8 |
static int
|
|
|
4728c8 |
dump_config (void)
|
|
|
4728c8 |
{
|
|
|
4728c8 |
- char * c;
|
|
|
4728c8 |
+ char * c, * tmp = NULL;
|
|
|
4728c8 |
char * reply;
|
|
|
4728c8 |
unsigned int maxlen = 256;
|
|
|
4728c8 |
int again = 1;
|
|
|
4728c8 |
@@ -402,9 +402,12 @@ dump_config (void)
|
|
|
4728c8 |
reply = MALLOC(maxlen);
|
|
|
4728c8 |
|
|
|
4728c8 |
while (again) {
|
|
|
4728c8 |
- if (!reply)
|
|
|
4728c8 |
+ if (!reply) {
|
|
|
4728c8 |
+ if (tmp)
|
|
|
4728c8 |
+ free(tmp);
|
|
|
4728c8 |
return 1;
|
|
|
4728c8 |
- c = reply;
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
+ c = tmp = reply;
|
|
|
4728c8 |
c += snprint_defaults(c, reply + maxlen - c);
|
|
|
4728c8 |
again = ((c - reply) == maxlen);
|
|
|
4728c8 |
if (again) {
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/cli_handlers.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/cli_handlers.c
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/cli_handlers.c
|
|
|
4728c8 |
@@ -26,11 +26,14 @@
|
|
|
4728c8 |
#define REALLOC_REPLY(r, a, m) \
|
|
|
4728c8 |
do { \
|
|
|
4728c8 |
if ((a)) { \
|
|
|
4728c8 |
+ char *tmp = (r); \
|
|
|
4728c8 |
(r) = REALLOC((r), (m) * 2); \
|
|
|
4728c8 |
if ((r)) { \
|
|
|
4728c8 |
memset((r) + (m), 0, (m)); \
|
|
|
4728c8 |
(m) *= 2; \
|
|
|
4728c8 |
} \
|
|
|
4728c8 |
+ else \
|
|
|
4728c8 |
+ free(tmp); \
|
|
|
4728c8 |
} \
|
|
|
4728c8 |
} while (0)
|
|
|
4728c8 |
|
|
|
4728c8 |
@@ -144,7 +147,7 @@ show_config (char ** r, int * len)
|
|
|
4728c8 |
unsigned int maxlen = INITIAL_REPLY_LEN;
|
|
|
4728c8 |
int again = 1;
|
|
|
4728c8 |
|
|
|
4728c8 |
- reply = MALLOC(maxlen);
|
|
|
4728c8 |
+ c = reply = MALLOC(maxlen);
|
|
|
4728c8 |
|
|
|
4728c8 |
while (again) {
|
|
|
4728c8 |
if (!reply)
|
|
|
4728c8 |
@@ -152,44 +155,24 @@ show_config (char ** r, int * len)
|
|
|
4728c8 |
c = reply;
|
|
|
4728c8 |
c += snprint_defaults(c, reply + maxlen - c);
|
|
|
4728c8 |
again = ((c - reply) == maxlen);
|
|
|
4728c8 |
- if (again) {
|
|
|
4728c8 |
- reply = REALLOC(reply, maxlen * 2);
|
|
|
4728c8 |
- if (!reply)
|
|
|
4728c8 |
- return 1;
|
|
|
4728c8 |
- memset(reply + maxlen, 0, maxlen);
|
|
|
4728c8 |
- maxlen *= 2;
|
|
|
4728c8 |
+ REALLOC_REPLY(reply, again, maxlen);
|
|
|
4728c8 |
+ if (again)
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
c += snprint_blacklist(c, reply + maxlen - c);
|
|
|
4728c8 |
again = ((c - reply) == maxlen);
|
|
|
4728c8 |
- if (again) {
|
|
|
4728c8 |
- reply = REALLOC(reply, maxlen * 2);
|
|
|
4728c8 |
- if (!reply)
|
|
|
4728c8 |
- return 1;
|
|
|
4728c8 |
- memset(reply + maxlen, 0, maxlen);
|
|
|
4728c8 |
- maxlen *= 2;
|
|
|
4728c8 |
+ REALLOC_REPLY(reply, again, maxlen);
|
|
|
4728c8 |
+ if (again)
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
c += snprint_blacklist_except(c, reply + maxlen - c);
|
|
|
4728c8 |
again = ((c - reply) == maxlen);
|
|
|
4728c8 |
- if (again) {
|
|
|
4728c8 |
- reply = REALLOC(reply, maxlen * 2);
|
|
|
4728c8 |
- if (!reply)
|
|
|
4728c8 |
- return 1;
|
|
|
4728c8 |
- memset(reply + maxlen, 0, maxlen);
|
|
|
4728c8 |
- maxlen *= 2;
|
|
|
4728c8 |
+ REALLOC_REPLY(reply, again, maxlen);
|
|
|
4728c8 |
+ if (again)
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
c += snprint_hwtable(c, reply + maxlen - c, conf->hwtable);
|
|
|
4728c8 |
again = ((c - reply) == maxlen);
|
|
|
4728c8 |
- if (again) {
|
|
|
4728c8 |
- reply = REALLOC(reply, maxlen * 2);
|
|
|
4728c8 |
- if (!reply)
|
|
|
4728c8 |
- return 1;
|
|
|
4728c8 |
- memset(reply + maxlen, 0, maxlen);
|
|
|
4728c8 |
- maxlen *= 2;
|
|
|
4728c8 |
+ REALLOC_REPLY(reply, again, maxlen);
|
|
|
4728c8 |
+ if (again)
|
|
|
4728c8 |
continue;
|
|
|
4728c8 |
- }
|
|
|
4728c8 |
c += snprint_mptable(c, reply + maxlen - c, conf->mptable);
|
|
|
4728c8 |
again = ((c - reply) == maxlen);
|
|
|
4728c8 |
REALLOC_REPLY(reply, again, maxlen);
|
|
|
4728c8 |
Index: multipath-tools-130222/multipathd/uxlsnr.c
|
|
|
4728c8 |
===================================================================
|
|
|
4728c8 |
--- multipath-tools-130222.orig/multipathd/uxlsnr.c
|
|
|
4728c8 |
+++ multipath-tools-130222/multipathd/uxlsnr.c
|
|
|
4728c8 |
@@ -64,6 +64,10 @@ static void new_client(int ux_sock)
|
|
|
4728c8 |
|
|
|
4728c8 |
/* put it in our linked list */
|
|
|
4728c8 |
c = (struct client *)MALLOC(sizeof(*c));
|
|
|
4728c8 |
+ if (!c) {
|
|
|
4728c8 |
+ close(fd);
|
|
|
4728c8 |
+ return;
|
|
|
4728c8 |
+ }
|
|
|
4728c8 |
memset(c, 0, sizeof(*c));
|
|
|
4728c8 |
c->fd = fd;
|
|
|
4728c8 |
c->next = clients;
|
|
|
4728c8 |
@@ -124,11 +128,18 @@ void * uxsock_listen(int (*uxsock_trigge
|
|
|
4728c8 |
sigdelset(&mask, SIGHUP);
|
|
|
4728c8 |
sigdelset(&mask, SIGUSR1);
|
|
|
4728c8 |
while (1) {
|
|
|
4728c8 |
+ struct pollfd *tmp;
|
|
|
4728c8 |
struct client *c;
|
|
|
4728c8 |
int i, poll_count;
|
|
|
4728c8 |
|
|
|
4728c8 |
/* setup for a poll */
|
|
|
4728c8 |
- polls = REALLOC(polls, (1+num_clients) * sizeof(*polls));
|
|
|
4728c8 |
+ tmp = REALLOC(polls, (1+num_clients) * sizeof(*polls));
|
|
|
4728c8 |
+ /* If we can't allocate poliing space for the new client,
|
|
|
4728c8 |
+ * close it */
|
|
|
4728c8 |
+ if (!tmp)
|
|
|
4728c8 |
+ dead_client(clients);
|
|
|
4728c8 |
+ else
|
|
|
4728c8 |
+ polls = tmp;
|
|
|
4728c8 |
polls[0].fd = ux_sock;
|
|
|
4728c8 |
polls[0].events = POLLIN;
|
|
|
4728c8 |
|