File: socketpair.c

package info (click to toggle)
trinity 1.9%2Bgit20200331.4d2343bd18c7b-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,080 kB
  • sloc: ansic: 32,746; sh: 536; makefile: 164
file content (33 lines) | stat: -rw-r--r-- 763 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol, int __user *, usockvec)
 */
#include <stdlib.h>
#include <sys/socket.h>
#include "sanitise.h"
#include "utils.h"

static void sanitise_socketpair(struct syscallrecord *rec)
{
	rec->a1 = AF_UNIX;
	rec->a4 = (unsigned long) malloc(sizeof(int) * 2);
}

static void post_socketpair(struct syscallrecord *rec)
{
	//TODO: on success we should put the fd's that
	// were created into a child-local fd array.

	freeptr(&rec->a4);
}

struct syscallentry syscall_socketpair = {
	.name = "socketpair",
	.num_args = 4,
	.arg1name = "family",
	.arg2name = "type",
	.arg3name = "protocol",
	.arg4name = "usockvec",
	.arg4type = ARG_ADDRESS,
	.sanitise = sanitise_socketpair,
	.post = post_socketpair,
};