ScreenSaver: Didn't accept a one char password
* Sanitize (and pad) the salt passed to the crypt function * Made the password and confirm password control the same size. Fixes ticket #4466. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33069 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -82,6 +82,7 @@ PasswordWindow::_Setup()
|
|||||||
float width, height;
|
float width, height;
|
||||||
fConfirmControl->GetPreferredSize(&width, &height);
|
fConfirmControl->GetPreferredSize(&width, &height);
|
||||||
fPasswordControl->ResizeTo(width, height);
|
fPasswordControl->ResizeTo(width, height);
|
||||||
|
fConfirmControl->ResizeTo(width, height);
|
||||||
|
|
||||||
float divider = be_plain_font->StringWidth("Confirm password:") + 5.0;
|
float divider = be_plain_font->StringWidth("Confirm password:") + 5.0;
|
||||||
fConfirmControl->SetDivider(divider);
|
fConfirmControl->SetDivider(divider);
|
||||||
@@ -123,6 +124,44 @@ PasswordWindow::Update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *
|
||||||
|
PasswordWindow::_SanitizeSalt(const char *password)
|
||||||
|
{
|
||||||
|
char *salt;
|
||||||
|
|
||||||
|
uint8 length = strlen(password);
|
||||||
|
|
||||||
|
if (length < 2)
|
||||||
|
salt = new char[3];
|
||||||
|
else
|
||||||
|
salt = new char[length + 1];
|
||||||
|
|
||||||
|
uint8 i = 0;
|
||||||
|
uint8 j = 0;
|
||||||
|
for (; i < length; i++) {
|
||||||
|
if ((password[i] >= 'A' && password[i] <= 'Z')
|
||||||
|
|| (password[i] >= 'a' && password[i] <= 'z')
|
||||||
|
|| (password[i] >= '0' && password[i] <= '9')
|
||||||
|
|| (password[i] == '.' || password[i] == '/')) {
|
||||||
|
salt[j] = password[i];
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need to pad the salt.
|
||||||
|
*/
|
||||||
|
while (j < 2) {
|
||||||
|
salt[j] = '.';
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
salt[j] = '\0';
|
||||||
|
|
||||||
|
return salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PasswordWindow::MessageReceived(BMessage *message)
|
PasswordWindow::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
@@ -136,8 +175,9 @@ PasswordWindow::MessageReceived(BMessage *message)
|
|||||||
alert->Go();
|
alert->Go();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fSettings.SetPassword(crypt(fPasswordControl->Text(),
|
const char *salt = _SanitizeSalt(fPasswordControl->Text());
|
||||||
fPasswordControl->Text()));
|
fSettings.SetPassword(crypt(fPasswordControl->Text(), salt));
|
||||||
|
delete salt;
|
||||||
} else {
|
} else {
|
||||||
fSettings.SetPassword("");
|
fSettings.SetPassword("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class PasswordWindow : public BWindow {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _Setup();
|
void _Setup();
|
||||||
|
char * _SanitizeSalt(const char *password);
|
||||||
|
|
||||||
BRadioButton *fUseCustom;
|
BRadioButton *fUseCustom;
|
||||||
BRadioButton *fUseNetwork;
|
BRadioButton *fUseNetwork;
|
||||||
|
|||||||
Reference in New Issue
Block a user