diff options
author | Wen Yang <wenyang@linux.alibaba.com> | 2020-02-19 14:44:42 +0100 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2020-03-29 23:20:07 +0200 |
commit | ba758cfce00a5977ccf019926f8379a96f5ac5f6 (patch) | |
tree | 9b353510e0df037045b6b48d62e7b16bcb5fe5ad /arch/um/os-Linux | |
parent | um: Don't use console_drivers directly (diff) | |
download | linux-ba758cfce00a5977ccf019926f8379a96f5ac5f6.tar.xz linux-ba758cfce00a5977ccf019926f8379a96f5ac5f6.zip |
um: Fix len of file in create_pid_file
sizeof gives us the size of the pointer variable, not of the
area it points to. So the number of bytes copied by umid_file_name()
is 8.
We should pass in the correct length of the file buffer.
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um/os-Linux')
-rw-r--r-- | arch/um/os-Linux/umid.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c index 44def53a11cd..9e16078a4bf8 100644 --- a/arch/um/os-Linux/umid.c +++ b/arch/um/os-Linux/umid.c @@ -220,11 +220,12 @@ static void __init create_pid_file(void) char pid[sizeof("nnnnn\0")], *file; int fd, n; - file = malloc(strlen(uml_dir) + UMID_LEN + sizeof("/pid\0")); + n = strlen(uml_dir) + UMID_LEN + sizeof("/pid\0"); + file = malloc(n); if (!file) return; - if (umid_file_name("pid", file, sizeof(file))) + if (umid_file_name("pid", file, n)) goto out; fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644); |