ssize_t len;
if (fd < 0) {
- ERR("Invalid file description");
+ ERR("Attempt to send invalid file descriptor to master (fd = %i)", fd);
+ /* Return 0 as this is not a fatal error. */
return 0;
}
{
ssize_t len;
- if (*fd < 0) {
- ERR("Invalid file description");
- return 0;
- }
-
len = lttcomm_recv_fds_unix_sock(sock, fd, 1);
if (!len) {
PERROR("lttcomm_recv_fds_unix_sock");
return -1;
}
+ if (*fd < 0) {
+ ERR("Invalid file descriptor received from worker (fd = %i)", *fd);
+ /* Return 0 as this is not a fatal error. */
+ return 0;
+ }
+
return 0;
}
return 0;
}
+ if (fd < 0) {
+ ERR("Refusing to send invalid fd to worker (fd = %i)", fd);
+ return -1;
+ }
+
ret = do_send_fd(worker->sockpair[0], fd);
if (ret < 0) {
PERROR("do_send_fd");
return 0;
}
+ if (fd < 0) {
+ DBG("Not sending file descriptor to master as it is invalid (fd = %i)", fd);
+ return 0;
+ }
ret = do_send_fd(worker->sockpair[1], fd);
if (ret < 0) {
PERROR("do_send_fd error");
return 0;
}
+ if (fd < 0) {
+ return 0;
+ }
ret = close(fd);
if (ret < 0) {
PERROR("close error");
run_as_fct cmd;
uid_t prev_euid;
+ memset(&sendret, 0, sizeof(sendret));
+ sendret.fd = -1;
+
/*
* Stage 1: Receive run_as_data struct from the master.
* The structure contains the command type and all the parameters needed for
if (data.gid != getegid()) {
ret = setegid(data.gid);
if (ret < 0) {
+ sendret._error = true;
+ sendret._errno = errno;
PERROR("setegid");
goto write_return;
}
if (data.uid != prev_euid) {
ret = seteuid(data.uid);
if (ret < 0) {
+ sendret._error = true;
+ sendret._errno = errno;
PERROR("seteuid");
goto write_return;
}
goto end;
}
+ if (ret_value->_error) {
+ /* Skip stage 5 on error as there will be no fd to receive. */
+ goto end;
+ }
+
/*
* Stage 5: Receive file descriptor if needed
*/
DBG("Socket closed unexpectedly... "
"Restarting the worker process");
ret = run_as_restart_worker(global_worker);
-
if (ret == -1) {
ERR("Failed to restart worker process.");
goto err;
struct run_as_data data;
struct run_as_ret ret;
+ memset(&data, 0, sizeof(data));
+ memset(&ret, 0, sizeof(ret));
+
DBG3("extract_elf_symbol_offset() on fd=%d and function=%s "
"with for uid %d and gid %d", fd, function, (int) uid, (int) gid);
struct run_as_data data;
struct run_as_ret ret;
+ memset(&data, 0, sizeof(data));
+ memset(&ret, 0, sizeof(ret));
+
DBG3("extract_sdt_probe_offsets() on fd=%d, probe_name=%s and "
"provider_name=%s with for uid %d and gid %d", fd, probe_name,
provider_name, (int) uid, (int) gid);