bin/multiuser: Fix PVS 1809 and 1896

Replace memset() with explicit_bzero(), since compiler could delete
memset() funnction call.

Change-Id: I6d6ad991951f516cf94b6fdf1772715ef4a42822
Reviewed-on: https://review.haiku-os.org/c/880
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Murai Takashi 2019-01-12 09:17:59 +09:00 committed by waddlesplash
parent 2876fb7c18
commit ef916ff3b5
4 changed files with 9 additions and 7 deletions

View File

@ -6,14 +6,16 @@ UsePrivateHeaders kernel ;
# for <util/KMessage.h>
UsePrivateHeaders libroot ;
UsePrivateHeaders shared ;
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
SubDirC++Flags [ FDefines _BSD_SOURCE=1 ] ;
StaticLibrary libmultiuser_utils.a : multiuser_utils.cpp ;
BinCommand login : login.cpp : libmultiuser_utils.a ;
BinCommand login : login.cpp : libmultiuser_utils.a libbsd.so ;
BinCommand su : su.cpp : libmultiuser_utils.a ;
BinCommand su : su.cpp : libmultiuser_utils.a libbsd.so ;
BinCommand passwd : passwd.cpp : libmultiuser_utils.a ;
BinCommand passwd : passwd.cpp : libmultiuser_utils.a libbsd.so ;
BinCommand useradd : useradd.cpp ;

View File

@ -91,7 +91,7 @@ login(const char* user, struct passwd** _passwd)
struct spwd* spwd = getspnam(user);
bool ok = verify_password(passwd, spwd, password);
memset(password, 0, sizeof(password));
explicit_bzero(password, sizeof(password));
if (!ok)
return B_PERMISSION_DENIED;

View File

@ -140,7 +140,7 @@ authenticate_user(const char* prompt, passwd* passwd, spwd* spwd, int maxTries,
// check it
bool ok = verify_password(passwd, spwd, plainPassword);
memset(plainPassword, 0, sizeof(plainPassword));
explicit_bzero(plainPassword, sizeof(plainPassword));
if (ok)
return B_OK;

View File

@ -169,11 +169,11 @@ main(int argc, const char* const* argv)
exit(1);
}
memset(repeatedPassword, 0, sizeof(repeatedPassword));
explicit_bzero(repeatedPassword, sizeof(repeatedPassword));
// crypt it
encryptedPassword = crypt(password, NULL);
memset(password, 0, sizeof(password));
explicit_bzero(password, sizeof(password));
}
// prepare request for the registrar