vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / os / launch.cpp
blob025cbc652323ba7ce8b3eb48ab0dfb0dbaf0e301
1 /*
2 * Copyright 2015, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <launch.h>
9 #include <TokenSpace.h>
10 #include <util/KMessage.h>
13 static port_id sLaunchDaemonPort = -1;
16 port_id
17 BPrivate::get_launch_daemon_port()
19 if (sLaunchDaemonPort < 0) {
20 sLaunchDaemonPort = find_port(B_LAUNCH_DAEMON_PORT_NAME);
22 port_info info;
23 if (get_port_info(sLaunchDaemonPort, &info) == B_OK
24 && info.team == find_thread(NULL)) {
25 // Make sure that the launch_daemon doesn't wait on itself
26 sLaunchDaemonPort = -1;
27 return -1;
31 return sLaunchDaemonPort;
35 status_t
36 BPrivate::send_request_to_launch_daemon(KMessage& request, KMessage& reply)
38 status_t status = request.SendTo(get_launch_daemon_port(),
39 B_PREFERRED_TOKEN, &reply);
40 if (status != B_OK)
41 return status;
43 return (status_t)reply.What();
47 status_t
48 BPrivate::get_launch_data(const char* signature, KMessage& data)
50 BPrivate::KMessage request(B_GET_LAUNCH_DATA);
51 request.AddString("name", signature);
53 return BPrivate::send_request_to_launch_daemon(request, data);