Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4833d9f4 authored by Tom Zhu's avatar Tom Zhu Committed by San Mehat
Browse files

init: builtins: trancate target file in do_copy



add O_TRUNC flag in open(), which will truncate the target file,
otherwise, copy will keep the old content of the target file.

Signed-off-by: default avatarTom Zhu <ling.zhu@motorola.com>
Signed-off-by: default avatarSan Mehat <san@google.com>
parent 04ea5b97
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -445,7 +445,7 @@ int do_copy(int nargs, char **args)
    if ((fd1 = open(args[1], O_RDONLY)) < 0) 
        goto out_err;

    if ((fd2 = open(args[2], O_WRONLY|O_CREAT, 0660)) < 0)
    if ((fd2 = open(args[2], O_WRONLY|O_CREAT|O_TRUNC, 0660)) < 0)
        goto out_err;

    if (!(buffer = malloc(info.st_size)))