mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
cstp_send_file: use system calls instead of libc for open/read
That simplifies the handling of seccomp rules.
This commit is contained in:
11
src/tlslib.c
11
src/tlslib.c
@@ -112,23 +112,24 @@ ssize_t cstp_send(worker_st *ws, const void *data,
|
||||
|
||||
ssize_t cstp_send_file(worker_st *ws, const char *file)
|
||||
{
|
||||
FILE* fp;
|
||||
int fd;
|
||||
char buf[512];
|
||||
ssize_t len, total = 0;
|
||||
int ret;
|
||||
|
||||
fp = fopen(file, "r");
|
||||
if (fp == NULL)
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return GNUTLS_E_FILE_ERROR;
|
||||
|
||||
while ( (len = fread( buf, 1, sizeof(buf), fp)) > 0) {
|
||||
while ( (len = read( fd, buf, sizeof(buf))) > 0 ||
|
||||
(len == -1 && (errno == EINTR || errno == EAGAIN))) {
|
||||
ret = cstp_send(ws, buf, len);
|
||||
FATAL_ERR(ws, ret);
|
||||
|
||||
total += ret;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
close(fd);
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -102,8 +102,7 @@ int disable_system_calls(struct worker_st *ws)
|
||||
|
||||
/* we need to open files when we have an xml_config_file setup */
|
||||
if (ws->config->xml_config_file) {
|
||||
ADD_SYSCALL(fstat, 0);
|
||||
ADD_SYSCALL(lseek, 0);
|
||||
ADD_SYSCALL(stat, 0);
|
||||
ADD_SYSCALL(open, 0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user