diff options
author | unknown <petr@mysql.com> | 2005-02-13 15:13:33 +0300 |
---|---|---|
committer | unknown <petr@mysql.com> | 2005-02-13 15:13:33 +0300 |
commit | 5bd607785a1f72b826831ab45c99d75b69846531 (patch) | |
tree | 0416b3a77d516d448dfd5239dadc5bf9e7583bcc /server-tools/instance-manager/parse_output.cc | |
parent | dce2554f9130920ab18e4e31432df7d6ca165ee0 (diff) | |
download | mariadb-git-5bd607785a1f72b826831ab45c99d75b69846531.tar.gz |
various fixes
server-tools/instance-manager/buffer.cc:
use my_realloc instead of realloc
server-tools/instance-manager/buffer.h:
use my_malloc instead of malloc
server-tools/instance-manager/commands.cc:
No need to send a buffer if there were some error while writing to it
server-tools/instance-manager/instance_options.cc:
cleanup
server-tools/instance-manager/manager.cc:
check sigwait return value
server-tools/instance-manager/parse_output.cc:
fixed a bug, found with valgrind
Diffstat (limited to 'server-tools/instance-manager/parse_output.cc')
-rw-r--r-- | server-tools/instance-manager/parse_output.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/server-tools/instance-manager/parse_output.cc b/server-tools/instance-manager/parse_output.cc index 4276062caf2..317970d2047 100644 --- a/server-tools/instance-manager/parse_output.cc +++ b/server-tools/instance-manager/parse_output.cc @@ -36,6 +36,10 @@ DESCRIPTION Parse output of the "command". Find the "word" and return the next one + + RETURN + 0 - ok + 1 - error occured */ int parse_output_and_get_value(const char *command, const char *word, @@ -49,7 +53,8 @@ int parse_output_and_get_value(const char *command, const char *word, wordlen= strlen(word); - output= popen(command, "r"); + if ((output= popen(command, "r")) == NULL) + goto err; /* We want fully buffered stream. We also want system to @@ -69,15 +74,18 @@ int parse_output_and_get_value(const char *command, const char *word, these are '/', '-' and '.' in the path expressions and filenames) */ get_word((const char **) &linep, &lineword_len, NONSPACE); - if (!strncmp(word, linep, wordlen) && *result != '\0') + if (!strncmp(word, linep, wordlen)) { /* If we have found the word, return the next one. This is usually an option value. */ + linep+= lineword_len; /* swallow the previous one */ get_word((const char **) &linep, &lineword_len, NONSPACE); - DBUG_ASSERT(result_len > lineword_len); + if (result_len <= lineword_len) + goto err; strncpy(result, linep, lineword_len); + result[lineword_len]= '\0'; goto pclose; } } @@ -87,4 +95,7 @@ pclose: return 1; return 0; + +err: + return 1; } |