|
@@ -28,6 +28,7 @@ int ovr_open(struct s_sandboxenv *env)
|
|
|
{
|
|
{
|
|
|
char *pathname = getMem(env, (size_t) env->syscall_args[0], NULL);
|
|
char *pathname = getMem(env, (size_t) env->syscall_args[0], NULL);
|
|
|
int flags = (int) env->syscall_args[1];
|
|
int flags = (int) env->syscall_args[1];
|
|
|
|
|
+ size_t fsize;
|
|
|
mode_t mode = (mode_t) env->syscall_args[2];
|
|
mode_t mode = (mode_t) env->syscall_args[2];
|
|
|
int ro = !(flags & (O_RDWR | O_WRONLY | O_TRUNC));
|
|
int ro = !(flags & (O_RDWR | O_WRONLY | O_TRUNC));
|
|
|
t_fileinfo *fileentry;
|
|
t_fileinfo *fileentry;
|
|
@@ -36,7 +37,7 @@ int ovr_open(struct s_sandboxenv *env)
|
|
|
if (*pathname != '/')
|
|
if (*pathname != '/')
|
|
|
find_fullpath(&pathname, 1);
|
|
find_fullpath(&pathname, 1);
|
|
|
fileentry = get_fileinfo(env, pathname);
|
|
fileentry = get_fileinfo(env, pathname);
|
|
|
- if (!fileentry && ro && (flags & O_CREAT) && !file_exists(pathname))
|
|
|
|
|
|
|
+ if (!fileentry && ro && (flags & O_CREAT) && !file_exists_getFilesize(pathname, &fsize))
|
|
|
ro = 0;
|
|
ro = 0;
|
|
|
if (!fileentry && ro)
|
|
if (!fileentry && ro)
|
|
|
{
|
|
{
|
|
@@ -52,6 +53,10 @@ int ovr_open(struct s_sandboxenv *env)
|
|
|
fd->fd = (int) env->syscall_no.syscall_return;
|
|
fd->fd = (int) env->syscall_no.syscall_return;
|
|
|
fd->flags = flags;
|
|
fd->flags = flags;
|
|
|
fd->mod = mode;
|
|
fd->mod = mode;
|
|
|
|
|
+ if (flags & O_APPEND)
|
|
|
|
|
+ fd->offset = fsize;
|
|
|
|
|
+ else
|
|
|
|
|
+ fd->offset = 0;
|
|
|
sllist_pushback(fileentry->fds, fd);
|
|
sllist_pushback(fileentry->fds, fd);
|
|
|
|
|
|
|
|
free(pathname);
|
|
free(pathname);
|