projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: lttng-ctl: unvalidated session destruction handle API arguments
[lttng-tools.git]
/
src
/
lib
/
lttng-ctl
/
destruction-handle.c
diff --git
a/src/lib/lttng-ctl/destruction-handle.c
b/src/lib/lttng-ctl/destruction-handle.c
index e22deaa930ef86fd74f25f58df6d156d39591aec..d2559646f8c18201f0a16e70cfffd9f81fe6aa2c 100644
(file)
--- a/
src/lib/lttng-ctl/destruction-handle.c
+++ b/
src/lib/lttng-ctl/destruction-handle.c
@@
-243,6
+243,11
@@
lttng_destruction_handle_wait_for_completion(
const bool has_timeout = timeout_ms > 0;
struct timespec initial_time;
const bool has_timeout = timeout_ms > 0;
struct timespec initial_time;
+ if (!handle) {
+ status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
+ goto end;
+ }
+
if (handle->communication.state == COMMUNICATION_STATE_ERROR) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR;
goto end;
if (handle->communication.state == COMMUNICATION_STATE_ERROR) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_ERROR;
goto end;
@@
-329,6
+334,11
@@
lttng_destruction_handle_get_rotation_state(
enum lttng_destruction_handle_status status =
LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
enum lttng_destruction_handle_status status =
LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
+ if (!handle || !rotation_state) {
+ status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
+ goto end;
+ }
+
if (!handle->rotation_state.is_set) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
goto end;
if (!handle->rotation_state.is_set) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
goto end;
@@
-346,6
+356,11
@@
lttng_destruction_handle_get_archive_location(
enum lttng_destruction_handle_status status =
LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
enum lttng_destruction_handle_status status =
LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
+ if (!handle || !location) {
+ status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
+ goto end;
+ }
+
if (!handle->location) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
goto end;
if (!handle->location) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
goto end;
@@
-363,6
+378,11
@@
lttng_destruction_handle_get_result(
enum lttng_destruction_handle_status status =
LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
enum lttng_destruction_handle_status status =
LTTNG_DESTRUCTION_HANDLE_STATUS_OK;
+ if (!handle || !result) {
+ status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
+ goto end;
+ }
+
if (!handle->destruction_return_code.is_set) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
goto end;
if (!handle->destruction_return_code.is_set) {
status = LTTNG_DESTRUCTION_HANDLE_STATUS_INVALID;
goto end;
@@
-384,6
+404,11
@@
enum lttng_error_code lttng_destroy_session_ext(const char *session_name,
int sessiond_socket = -1;
struct lttng_destruction_handle *handle = NULL;
int sessiond_socket = -1;
struct lttng_destruction_handle *handle = NULL;
+ if (!session_name || !handle) {
+ ret_code = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
ret = lttng_strncpy(lsm.session.name, session_name,
sizeof(lsm.session.name));
if (ret) {
ret = lttng_strncpy(lsm.session.name, session_name,
sizeof(lsm.session.name));
if (ret) {
@@
-405,7
+430,7
@@
enum lttng_error_code lttng_destroy_session_ext(const char *session_name,
goto error;
}
goto error;
}
- comm_ret = lttcomm_send_unix_sock(sessiond_socket, &lsm, sizeof(lsm));
+ comm_ret = lttcomm_send_
creds_
unix_sock(sessiond_socket, &lsm, sizeof(lsm));
if (comm_ret < 0) {
ret_code = LTTNG_ERR_FATAL;
goto error;
if (comm_ret < 0) {
ret_code = LTTNG_ERR_FATAL;
goto error;
@@
-420,7
+445,9
@@
enum lttng_error_code lttng_destroy_session_ext(const char *session_name,
error:
if (sessiond_socket >= 0) {
ret = close(sessiond_socket);
error:
if (sessiond_socket >= 0) {
ret = close(sessiond_socket);
- PERROR("Failed to close the LTTng session daemon connection socket");
+ if (ret < 0) {
+ PERROR("Failed to close the LTTng session daemon connection socket");
+ }
}
if (handle) {
lttng_destruction_handle_destroy(handle);
}
if (handle) {
lttng_destruction_handle_destroy(handle);
This page took
0.024916 seconds
and
4
git commands to generate.