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 dereference of null pointers
[lttng-tools.git]
/
src
/
bin
/
lttng-relayd
/
cmd-2-1.c
diff --git
a/src/bin/lttng-relayd/cmd-2-1.c
b/src/bin/lttng-relayd/cmd-2-1.c
index 1942dee0a23dab0ab090e9a03794492946316955..32a94386f3ef8171191f15cfcbc63de3ab6b2a5f 100644
(file)
--- a/
src/bin/lttng-relayd/cmd-2-1.c
+++ b/
src/bin/lttng-relayd/cmd-2-1.c
@@
-1,6
+1,7
@@
/*
* Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
* David Goulet <dgoulet@efficios.com>
/*
* Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
* David Goulet <dgoulet@efficios.com>
+ * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 2 only, as
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License, version 2 only, as
@@
-17,6
+18,7
@@
*/
#define _GNU_SOURCE
*/
#define _GNU_SOURCE
+#define _LGPL_SOURCE
#include <assert.h>
#include <string.h>
#include <assert.h>
#include <string.h>
@@
-27,35
+29,42
@@
#include "cmd-2-1.h"
#include "utils.h"
#include "cmd-2-1.h"
#include "utils.h"
-int cmd_recv_stream_2_1(struct relay_command *cmd, struct relay_stream *stream)
+/*
+ * cmd_recv_stream_2_1 allocates path_name and channel_name.
+ */
+int cmd_recv_stream_2_1(struct relay_connection *conn,
+ char **ret_path_name, char **ret_channel_name)
{
int ret;
struct lttcomm_relayd_add_stream stream_info;
{
int ret;
struct lttcomm_relayd_add_stream stream_info;
+ char *path_name = NULL;
+ char *channel_name = NULL;
- assert(cmd);
- assert(stream);
-
- ret = cmd_recv(cmd->sock, &stream_info, sizeof(stream_info));
+ ret = cmd_recv(conn->sock, &stream_info, sizeof(stream_info));
if (ret < 0) {
ERR("Unable to recv stream version 2.1");
goto error;
}
if (ret < 0) {
ERR("Unable to recv stream version 2.1");
goto error;
}
-
stream->
path_name = create_output_path(stream_info.pathname);
- if (
stream->path_name == NULL
) {
+ path_name = create_output_path(stream_info.pathname);
+ if (
!path_name
) {
PERROR("Path name allocation");
ret = -ENOMEM;
goto error;
}
PERROR("Path name allocation");
ret = -ENOMEM;
goto error;
}
-
stream->
channel_name = strdup(stream_info.channel_name);
- if (
stream->channel_name == NULL
) {
+ channel_name = strdup(stream_info.channel_name);
+ if (
!channel_name
) {
ret = -errno;
PERROR("Path name allocation");
goto error;
}
ret = -errno;
PERROR("Path name allocation");
goto error;
}
- ret = 0;
+ *ret_path_name = path_name;
+ *ret_channel_name = channel_name;
+ return 0;
error:
error:
+ free(path_name);
+ free(channel_name);
return ret;
}
return ret;
}
This page took
0.025662 seconds
and
4
git commands to generate.