projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: string comparison on incorrect length in context provider
[lttng-ust.git]
/
liblttng-ust
/
lttng-ust-comm.c
diff --git
a/liblttng-ust/lttng-ust-comm.c
b/liblttng-ust/lttng-ust-comm.c
index 7cd6a227d66c3bede0f7e244a02038c2c8de668b..6c11288c8d2f2d571bbacd86163122da3e8a703a 100644
(file)
--- a/
liblttng-ust/lttng-ust-comm.c
+++ b/
liblttng-ust/lttng-ust-comm.c
@@
-365,11
+365,11
@@
const char *get_lttng_home_dir(void)
{
const char *val;
{
const char *val;
- val = (const char *) lttng_
secure_
getenv("LTTNG_HOME");
+ val = (const char *) lttng_getenv("LTTNG_HOME");
if (val != NULL) {
return val;
}
if (val != NULL) {
return val;
}
- return (const char *) lttng_
secure_
getenv("HOME");
+ return (const char *) lttng_getenv("HOME");
}
/*
}
/*
@@
-470,7
+470,7
@@
long get_timeout(void)
long constructor_delay_ms = LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS;
if (!got_timeout_env) {
long constructor_delay_ms = LTTNG_UST_DEFAULT_CONSTRUCTOR_TIMEOUT_MS;
if (!got_timeout_env) {
- str_timeout = getenv("LTTNG_UST_REGISTER_TIMEOUT");
+ str_timeout =
lttng_
getenv("LTTNG_UST_REGISTER_TIMEOUT");
got_timeout_env = 1;
}
if (str_timeout)
got_timeout_env = 1;
}
if (str_timeout)
@@
-1247,7
+1247,18
@@
char *get_map_shm(struct sock_info *sock_info)
lttng_ust_unlock_fd_tracker();
goto error;
}
lttng_ust_unlock_fd_tracker();
goto error;
}
- lttng_ust_add_fd_to_tracker(wait_shm_fd);
+
+ ret = lttng_ust_add_fd_to_tracker(wait_shm_fd);
+ if (ret < 0) {
+ ret = close(wait_shm_fd);
+ if (!ret) {
+ PERROR("Error closing fd");
+ }
+ lttng_ust_unlock_fd_tracker();
+ goto error;
+ }
+
+ wait_shm_fd = ret;
lttng_ust_unlock_fd_tracker();
wait_shm_mmap = mmap(NULL, page_size, PROT_READ,
lttng_ust_unlock_fd_tracker();
wait_shm_mmap = mmap(NULL, page_size, PROT_READ,
@@
-1339,7
+1350,7
@@
static
void *ust_listener_thread(void *arg)
{
struct sock_info *sock_info = arg;
void *ust_listener_thread(void *arg)
{
struct sock_info *sock_info = arg;
- int sock, ret, prev_connect_failed = 0, has_waited = 0;
+ int sock, ret, prev_connect_failed = 0, has_waited = 0
, fd
;
long timeout;
lttng_ust_fixup_tls();
long timeout;
lttng_ust_fixup_tls();
@@
-1371,6
+1382,10
@@
restart:
prev_connect_failed = 0;
}
prev_connect_failed = 0;
}
+ if (ust_lock()) {
+ goto quit;
+ }
+
if (sock_info->socket != -1) {
/* FD tracker is updated by ustcomm_close_unix_sock() */
ret = ustcomm_close_unix_sock(sock_info->socket);
if (sock_info->socket != -1) {
/* FD tracker is updated by ustcomm_close_unix_sock() */
ret = ustcomm_close_unix_sock(sock_info->socket);
@@
-1390,9
+1405,6
@@
restart:
sock_info->notify_socket = -1;
}
sock_info->notify_socket = -1;
}
- if (ust_lock()) {
- goto quit;
- }
/*
* Register. We need to perform both connect and sending
/*
* Register. We need to perform both connect and sending
@@
-1419,9
+1431,21
@@
restart:
ust_unlock();
goto restart;
}
ust_unlock();
goto restart;
}
- lttng_ust_add_fd_to_tracker(ret);
- lttng_ust_unlock_fd_tracker();
+ fd = ret;
+ ret = lttng_ust_add_fd_to_tracker(fd);
+ if (ret < 0) {
+ ret = close(fd);
+ if (ret) {
+ PERROR("close on sock_info->socket");
+ }
+ ret = -1;
+ lttng_ust_unlock_fd_tracker();
+ ust_unlock();
+ goto quit;
+ }
+
sock_info->socket = ret;
sock_info->socket = ret;
+ lttng_ust_unlock_fd_tracker();
ust_unlock();
/*
ust_unlock();
/*
@@
-1490,9
+1514,22
@@
restart:
ust_unlock();
goto restart;
}
ust_unlock();
goto restart;
}
- lttng_ust_add_fd_to_tracker(ret);
- lttng_ust_unlock_fd_tracker();
+
+ fd = ret;
+ ret = lttng_ust_add_fd_to_tracker(fd);
+ if (ret < 0) {
+ ret = close(fd);
+ if (ret) {
+ PERROR("close on sock_info->notify_socket");
+ }
+ ret = -1;
+ lttng_ust_unlock_fd_tracker();
+ ust_unlock();
+ goto quit;
+ }
+
sock_info->notify_socket = ret;
sock_info->notify_socket = ret;
+ lttng_ust_unlock_fd_tracker();
ust_unlock();
/*
ust_unlock();
/*
@@
-1654,6
+1691,7
@@
void __attribute__((constructor)) lttng_ust_init(void)
* sessiond before the init functions are completed).
*/
init_usterr();
* sessiond before the init functions are completed).
*/
init_usterr();
+ lttng_ust_getenv_init(); /* Needs init_usterr() to be completed. */
init_tracepoint();
lttng_ust_init_fd_tracker();
lttng_ust_clock_init();
init_tracepoint();
lttng_ust_init_fd_tracker();
lttng_ust_clock_init();
This page took
0.026574 seconds
and
4
git commands to generate.