Browse Source

LibC: Fix validation logic error in construct_pwd()

Previously this would've always succeeded, even if a copy failed.
Oops...
Ali Mohammad Pur 4 năm trước cách đây
mục cha
commit
ba294efd8e
1 tập tin đã thay đổi với 5 bổ sung5 xóa
  1. 5 5
      Userland/Libraries/LibC/pwd.cpp

+ 5 - 5
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);