summaryrefslogtreecommitdiff
path: root/LibC/grp.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-07 00:32:38 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-07 00:33:10 +0100
commitd3bd3791cb353966957ced0d208aa51107fe9ffc (patch)
treea72192e9e8e96dd1cf8087a15a3865cd892c9078 /LibC/grp.cpp
parent81359528321490740c6e7e69cab07076c505972b (diff)
downloadserenity-d3bd3791cb353966957ced0d208aa51107fe9ffc.zip
Minor fixes in getgrent() and getpwent() function families.
Diffstat (limited to 'LibC/grp.cpp')
-rw-r--r--LibC/grp.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/LibC/grp.cpp b/LibC/grp.cpp
index 0081ea48e6..d12cd699bc 100644
--- a/LibC/grp.cpp
+++ b/LibC/grp.cpp
@@ -87,10 +87,10 @@ next_entry:
assert(__grdb_stream);
if (feof(__grdb_stream))
return nullptr;
- String line(s);
+ String line(s, Chomp);
auto parts = line.split(':');
if (parts.size() != 4) {
- fprintf(stderr, "getgrent(): Malformed entry on line %u\n", __grdb_line_number);
+ fprintf(stderr, "getgrent(): Malformed entry on line %u: '%s' has %u parts\n", __grdb_line_number, line.characters(), parts.size());
goto next_entry;
}
auto& e_name = parts[0];
@@ -107,11 +107,11 @@ next_entry:
__grdb_entry->gr_gid = e_gid;
__grdb_entry->gr_name = __grdb_entry->name_buffer;
__grdb_entry->gr_passwd = __grdb_entry->passwd_buffer;
- for (size_t i = 0; i < parts.size(); ++i) {
+ for (size_t i = 0; i < members.size(); ++i) {
__grdb_entry->members[i] = __grdb_entry->members_buffer[i];
- strcpy(__grdb_entry->members_buffer[i], parts[i].characters());
+ strcpy(__grdb_entry->members_buffer[i], members[i].characters());
}
- __grdb_entry->members[parts.size()] = nullptr;
+ __grdb_entry->members[members.size()] = nullptr;
__grdb_entry->gr_mem = __grdb_entry->members;
strncpy(__grdb_entry->name_buffer, e_name.characters(), GRDB_STR_MAX_LEN);
strncpy(__grdb_entry->passwd_buffer, e_passwd.characters(), GRDB_STR_MAX_LEN);