projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: validate expanded path NULL ptr in relayd
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
main.c
diff --git
a/src/bin/lttng-relayd/main.c
b/src/bin/lttng-relayd/main.c
index cd17dcd6720717e54fa9897d96a587c97bd68450..082eb7975efd0adb1c41bfbfee65c621dd34abeb 100644
(file)
--- a/
src/bin/lttng-relayd/main.c
+++ b/
src/bin/lttng-relayd/main.c
@@
-734,6
+734,10
@@
char *create_output_path_noauto(char *path_name)
char *full_path;
full_path = utils_expand_path(opt_output_path);
char *full_path;
full_path = utils_expand_path(opt_output_path);
+ if (!full_path) {
+ goto exit;
+ }
+
ret = asprintf(&traces_path, "%s/%s", full_path, path_name);
if (ret < 0) {
PERROR("asprintf trace dir name");
ret = asprintf(&traces_path, "%s/%s", full_path, path_name);
if (ret < 0) {
PERROR("asprintf trace dir name");
@@
-941,6
+945,7
@@
int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr,
ret = asprintf(&path, "%s/%s", root_path, stream_info.channel_name);
if (ret < 0) {
PERROR("asprintf stream path");
ret = asprintf(&path, "%s/%s", root_path, stream_info.channel_name);
if (ret < 0) {
PERROR("asprintf stream path");
+ path = NULL;
goto end;
}
goto end;
}
@@
-963,13
+968,17
@@
int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr,
end:
free(path);
free(root_path);
end:
free(path);
free(root_path);
+
+ reply.handle = htobe64(stream->stream_handle);
/* send the session id to the client or a negative return code on error */
if (ret < 0) {
reply.ret_code = htobe32(LTTNG_ERR_UNK);
/* send the session id to the client or a negative return code on error */
if (ret < 0) {
reply.ret_code = htobe32(LTTNG_ERR_UNK);
+ /* stream was not properly added to the ht, so free it */
+ free(stream);
} else {
reply.ret_code = htobe32(LTTNG_OK);
}
} else {
reply.ret_code = htobe32(LTTNG_OK);
}
- reply.handle = htobe64(stream->stream_handle);
+
send_ret = cmd->sock->ops->sendmsg(cmd->sock, &reply,
sizeof(struct lttcomm_relayd_status_stream), 0);
if (send_ret < 0) {
send_ret = cmd->sock->ops->sendmsg(cmd->sock, &reply,
sizeof(struct lttcomm_relayd_status_stream), 0);
if (send_ret < 0) {
@@
-2107,6
+2116,15
@@
int main(int argc, char **argv)
goto exit;
}
goto exit;
}
+ /* Try to create directory if -o, --output is specified. */
+ if (opt_output_path) {
+ ret = utils_mkdir_recursive(opt_output_path, S_IRWXU | S_IRWXG);
+ if (ret < 0) {
+ ERR("Unable to create %s", opt_output_path);
+ goto exit;
+ }
+ }
+
/* Daemonize */
if (opt_daemon) {
ret = daemon(0, 0);
/* Daemonize */
if (opt_daemon) {
ret = daemon(0, 0);
This page took
0.024742 seconds
and
4
git commands to generate.