mirror of
https://github.com/ipmitool/ipmitool.git
synced 2025-05-10 10:37:22 +00:00
user: Improve password length handling
No longer truncate passwords (16 < p <= 20) silently, instead attempt to set a 20-char password when such a password is given. Fail if an explicit length is exceeded, and any time the upper limit is exceeded.
This commit is contained in:
parent
af062a9a5e
commit
51a2ab8180
@ -657,24 +657,25 @@ ipmi_user_password(struct ipmi_intf *intf, int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
password = argv[3];
|
||||
if (argc > 4) {
|
||||
if ((str2uchar(argv[4], &password_type) != 0)
|
||||
|| (password_type != 16 && password_type != 20)) {
|
||||
lprintf(LOG_ERR, "Invalid password length '%s'", argv[4]);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
password_type = 16;
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 4) {
|
||||
if ((str2uchar(argv[4], &password_type) != 0)
|
||||
|| (password_type != 16 && password_type != 20)) {
|
||||
lprintf(LOG_ERR, "Invalid password length '%s'", argv[4]);
|
||||
return (-1);
|
||||
}
|
||||
} else if (strlen(password) > 16) {
|
||||
password_type = 20;
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
lprintf(LOG_ERR, "Unable to parse password argument.");
|
||||
return (-1);
|
||||
} else if (strlen(password) > 20) {
|
||||
lprintf(LOG_ERR, "Password is too long (> 20 bytes)");
|
||||
return (-1);
|
||||
}
|
||||
if (!password) {
|
||||
lprintf(LOG_ERR, "Unable to parse password argument.");
|
||||
return (-1);
|
||||
} else if (strlen(password) > password_type) {
|
||||
lprintf(LOG_ERR, "Password is too long (> %d bytes)", password_type);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ccode = _ipmi_set_user_password(intf, user_id,
|
||||
IPMI_PASSWORD_SET_PASSWORD, password,
|
||||
|
Loading…
x
Reference in New Issue
Block a user