mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Oops, fix null termination bug in getpwent().
This commit is contained in:
parent
3a901ae36d
commit
9da4864a9a
Notes:
sideshowbarker
2024-07-19 18:34:42 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9da4864a9a1
1 changed files with 12 additions and 10 deletions
22
LibC/pwd.cpp
22
LibC/pwd.cpp
|
@ -7,12 +7,14 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
#define PWDB_STR_MAX_LEN 256
|
||||
|
||||
struct passwd_with_strings : public passwd {
|
||||
char name_buffer[256];
|
||||
char passwd_buffer[256];
|
||||
char gecos_buffer[256];
|
||||
char dir_buffer[256];
|
||||
char shell_buffer[256];
|
||||
char name_buffer[PWDB_STR_MAX_LEN];
|
||||
char passwd_buffer[PWDB_STR_MAX_LEN];
|
||||
char gecos_buffer[PWDB_STR_MAX_LEN];
|
||||
char dir_buffer[PWDB_STR_MAX_LEN];
|
||||
char shell_buffer[PWDB_STR_MAX_LEN];
|
||||
};
|
||||
|
||||
static FILE* __pwdb_stream = nullptr;
|
||||
|
@ -117,11 +119,11 @@ next_entry:
|
|||
__pwdb_entry->pw_gecos = __pwdb_entry->gecos_buffer;
|
||||
__pwdb_entry->pw_dir = __pwdb_entry->dir_buffer;
|
||||
__pwdb_entry->pw_shell = __pwdb_entry->shell_buffer;
|
||||
strncpy(__pwdb_entry->name_buffer, e_name.characters(), e_name.length());
|
||||
strncpy(__pwdb_entry->passwd_buffer, e_passwd.characters(), e_passwd.length());
|
||||
strncpy(__pwdb_entry->gecos_buffer, e_gecos.characters(), e_gecos.length());
|
||||
strncpy(__pwdb_entry->dir_buffer, e_dir.characters(), e_dir.length());
|
||||
strncpy(__pwdb_entry->shell_buffer, e_shell.characters(), e_shell.length());
|
||||
strncpy(__pwdb_entry->name_buffer, e_name.characters(), PWDB_STR_MAX_LEN);
|
||||
strncpy(__pwdb_entry->passwd_buffer, e_passwd.characters(), PWDB_STR_MAX_LEN);
|
||||
strncpy(__pwdb_entry->gecos_buffer, e_gecos.characters(), PWDB_STR_MAX_LEN);
|
||||
strncpy(__pwdb_entry->dir_buffer, e_dir.characters(), PWDB_STR_MAX_LEN);
|
||||
strncpy(__pwdb_entry->shell_buffer, e_shell.characters(), PWDB_STR_MAX_LEN);
|
||||
return __pwdb_entry;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue