summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2021-04-29 23:55:12 +0430
committerAndreas Kling <kling@serenityos.org>2021-04-29 21:35:41 +0200
commitba294efd8e89a0c3e4c7b16bb99c9b9586c5e114 (patch)
tree123302ec50e023658b64276ab0499b486b4c0d8f /Userland
parenta8765fa6737315a07cf426378207a47c88ac52dd (diff)
downloadserenity-ba294efd8e89a0c3e4c7b16bb99c9b9586c5e114.zip
LibC: Fix validation logic error in construct_pwd()
Previously this would've always succeeded, even if a copy failed. Oops...
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibC/pwd.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibC/pwd.cpp b/Userland/Libraries/LibC/pwd.cpp
index 93390c33dd..d135acab09 100644
--- a/Userland/Libraries/LibC/pwd.cpp
+++ b/Userland/Libraries/LibC/pwd.cpp
@@ -152,11 +152,11 @@ static void construct_pwd(struct passwd* pwd, char* buf, struct passwd** result)
auto* buf_shell = &buf[s_dir.length() + 1 + s_gecos.length() + 1 + s_name.length() + 1 + s_gecos.length() + 1];
bool ok = true;
- ok = ok || s_name.copy_characters_to_buffer(buf_name, s_name.length() + 1);
- ok = ok || s_passwd.copy_characters_to_buffer(buf_passwd, s_passwd.length() + 1);
- ok = ok || s_gecos.copy_characters_to_buffer(buf_gecos, s_gecos.length() + 1);
- ok = ok || s_dir.copy_characters_to_buffer(buf_dir, s_dir.length() + 1);
- ok = ok || s_shell.copy_characters_to_buffer(buf_shell, s_shell.length() + 1);
+ ok = ok && s_name.copy_characters_to_buffer(buf_name, s_name.length() + 1);
+ ok = ok && s_passwd.copy_characters_to_buffer(buf_passwd, s_passwd.length() + 1);
+ ok = ok && s_gecos.copy_characters_to_buffer(buf_gecos, s_gecos.length() + 1);
+ ok = ok && s_dir.copy_characters_to_buffer(buf_dir, s_dir.length() + 1);
+ ok = ok && s_shell.copy_characters_to_buffer(buf_shell, s_shell.length() + 1);
VERIFY(ok);