Skip to content

Commit ba758cf

Browse files
tasksetrichardweinberger
authored andcommitted
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>
1 parent 7d7c056 commit ba758cf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎arch/um/os-Linux/umid.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,12 @@ static void __init create_pid_file(void)
220220
char pid[sizeof("nnnnn\0")], *file;
221221
int fd, n;
222222

223-
file = malloc(strlen(uml_dir) + UMID_LEN + sizeof("/pid\0"));
223+
n = strlen(uml_dir) + UMID_LEN + sizeof("/pid\0");
224+
file = malloc(n);
224225
if (!file)
225226
return;
226227

227-
if (umid_file_name("pid", file, sizeof(file)))
228+
if (umid_file_name("pid", file, n))
228229
goto out;
229230

230231
fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);

0 commit comments

Comments
 (0)