projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: Possible call to execvp with NULL argument on allocation failure
[lttng-tools.git]
/
src
/
bin
/
lttng
/
commands
/
view.c
diff --git
a/src/bin/lttng/commands/view.c
b/src/bin/lttng/commands/view.c
index 37fb4b8bc3a867ee06ff3e52b3c9155a7069e1a6..dba614c2f5733cf59ce5f5c62aaf0c2fc44119c8 100644
(file)
--- a/
src/bin/lttng/commands/view.c
+++ b/
src/bin/lttng/commands/view.c
@@
-152,7
+152,7
@@
static char **alloc_argv_from_user_opts(char *opts, const char *trace_path)
} while (*token != '\0');
/* Add two here for the NULL terminating element and trace path */
} while (*token != '\0');
/* Add two here for the NULL terminating element and trace path */
- argv = malloc(sizeof(char *) * (num_opts + 2));
+ argv =
z
malloc(sizeof(char *) * (num_opts + 2));
if (argv == NULL) {
goto error;
}
if (argv == NULL) {
goto error;
}
@@
-160,6
+160,9
@@
static char **alloc_argv_from_user_opts(char *opts, const char *trace_path)
token = strtok(opts, " ");
while (token != NULL) {
argv[i] = strdup(token);
token = strtok(opts, " ");
while (token != NULL) {
argv[i] = strdup(token);
+ if (argv[i] == NULL) {
+ goto error;
+ }
token = strtok(NULL, " ");
i++;
}
token = strtok(NULL, " ");
i++;
}
@@
-170,6
+173,13
@@
static char **alloc_argv_from_user_opts(char *opts, const char *trace_path)
return argv;
error:
return argv;
error:
+ if (argv) {
+ for (i = 0; i < num_opts + 2; i++) {
+ free(argv[i]);
+ }
+ free(argv);
+ }
+
return NULL;
}
return NULL;
}
@@
-199,7
+209,7
@@
static char **alloc_argv_from_local_opts(const char **opts, size_t opts_len,
size = sizeof(char *) * mem_len;
/* Add two here for the trace_path and the NULL terminating element. */
size = sizeof(char *) * mem_len;
/* Add two here for the trace_path and the NULL terminating element. */
- argv = malloc(size);
+ argv =
z
malloc(size);
if (argv == NULL) {
goto error;
}
if (argv == NULL) {
goto error;
}
@@
-272,7
+282,7
@@
static int spawn_viewer(const char *trace_path)
break;
}
break;
}
- if (argv == NULL) {
+ if (argv == NULL
|| !viewer_bin
) {
ret = CMD_FATAL;
goto error;
}
ret = CMD_FATAL;
goto error;
}
@@
-306,14
+316,14
@@
static char *build_live_path(char *session_name)
ret = gethostname(hostname, sizeof(hostname));
if (ret < 0) {
ret = gethostname(hostname, sizeof(hostname));
if (ret < 0) {
-
perror
("gethostname");
+
PERROR
("gethostname");
goto error;
}
ret = asprintf(&path, "net://localhost/host/%s/%s", hostname,
session_name);
if (ret < 0) {
goto error;
}
ret = asprintf(&path, "net://localhost/host/%s/%s", hostname,
session_name);
if (ret < 0) {
-
perror
("asprintf live path");
+
PERROR
("asprintf live path");
goto error;
}
goto error;
}
This page took
0.023595 seconds
and
4
git commands to generate.