}
extern "C" API int aul_sock_set_sock_option(int fd, int cli) {
+ if (fd < 0 || fd >= MAX_FDS) {
+ _E("Invalid parameter");
+ return -EINVAL;
+ }
+
int size = AUL_SOCK_MAXBUFF;
int ret = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
if (ret != 0)
extern "C" API int aul_sock_send_raw_with_fd(int fd, int cmd,
unsigned char* kb_data, int datalen, int opt) {
+ if (fd < 0 || fd >= MAX_FDS) {
+ _E("Invalid parameter");
+ return -EINVAL;
+ }
+
return SendAndReceive(fd, cmd, kb_data, datalen, opt);
}
extern "C" API int aul_sock_send_bundle_with_fd(int fd, int cmd, bundle* kb,
int opt) {
- if (kb == nullptr)
+ if (fd < 0 || fd >= MAX_FDS || kb == nullptr) {
+ _E("Invalid parameter");
return -EINVAL;
+ }
tizen_base::Bundle b(kb, false, false);
auto raw = b.ToRaw();
extern "C" API app_pkt_t* aul_sock_recv_pkt(int fd, int* clifd,
struct ucred* cred) {
+ if (fd < 0 || fd >= MAX_FDS) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
ServerSocket server(fd);
auto client = std::unique_ptr<ClientSocket>(server.Accept());
server.RemoveFd();
extern "C" API int aul_sock_recv_reply_sock_fd(int fd, int (*ret_fd)[2],
int fd_size) {
+ if (fd < 0 || fd >= MAX_FDS) {
+ _E("Invalid parameter");
+ return -EINVAL;
+ }
+
int fds[2] = { -1, -1 };
int vec_len = 0;
int fds_len = 0;
}
extern "C" API int aul_sock_recv_result_with_fd(int fd) {
+ if (fd < 0 || fd >= MAX_FDS) {
+ _E("Invalid parameter");
+ return -EINVAL;
+ }
+
ClientSocket client(fd);
int res;
int ret = client.Receive(&res, sizeof(res));
}
extern "C" API int aul_sock_destroy_server(int fd) {
- if (fd > -1)
+ if (fd > -1 && fd < MAX_FDS)
close(fd);
if (getuid() < REGULAR_UID_MIN) {
extern "C" API int aul_sock_recv_reply_pkt_v2(int fd, app_pkt_t** pkt,
bool do_close) {
- if (fd < 0 || fd >= MAX_FDS)
+ if (fd < 0 || fd >= MAX_FDS) {
+ _E("Invalid parameter");
return -EINVAL;
+ }
if (pkt == nullptr) {
+ _E("Invalid parameter");
if (do_close)
close(fd);