mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
Kernel: Let the process argv arrays be null-terminated.
Seems like this is expected. I don't know why I thought it wasn't.
This commit is contained in:
parent
2bedabbd6c
commit
0ebaa35aa1
1 changed files with 2 additions and 1 deletions
|
@ -543,13 +543,14 @@ int Process::sys$get_arguments(int* argc, char*** argv)
|
||||||
char* argpage = (char*)region->linearAddress.get();
|
char* argpage = (char*)region->linearAddress.get();
|
||||||
*argc = m_initial_arguments.size();
|
*argc = m_initial_arguments.size();
|
||||||
*argv = (char**)argpage;
|
*argv = (char**)argpage;
|
||||||
char* bufptr = argpage + (sizeof(char*) * m_initial_arguments.size());
|
char* bufptr = argpage + (sizeof(char*) * (m_initial_arguments.size() + 1));
|
||||||
for (size_t i = 0; i < m_initial_arguments.size(); ++i) {
|
for (size_t i = 0; i < m_initial_arguments.size(); ++i) {
|
||||||
(*argv)[i] = bufptr;
|
(*argv)[i] = bufptr;
|
||||||
memcpy(bufptr, m_initial_arguments[i].characters(), m_initial_arguments[i].length());
|
memcpy(bufptr, m_initial_arguments[i].characters(), m_initial_arguments[i].length());
|
||||||
bufptr += m_initial_arguments[i].length();
|
bufptr += m_initial_arguments[i].length();
|
||||||
*(bufptr++) = '\0';
|
*(bufptr++) = '\0';
|
||||||
}
|
}
|
||||||
|
(*argv)[m_initial_arguments.size()] = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue