legacy: Use snprintf instead of sprintf.
Found by Coverity.
Этот коммит содержится в:
родитель
2f8ddc6e65
Коммит
46f22576b0
@ -106,16 +106,17 @@ int ssh_userauth_privatekey_file(ssh_session session,
|
|||||||
ssh_private_key privkey = NULL;
|
ssh_private_key privkey = NULL;
|
||||||
int type = 0;
|
int type = 0;
|
||||||
int rc = SSH_AUTH_ERROR;
|
int rc = SSH_AUTH_ERROR;
|
||||||
|
size_t klen = strlen(filename) + 4 + 1;
|
||||||
|
|
||||||
enter_function();
|
enter_function();
|
||||||
|
|
||||||
pubkeyfile = malloc(strlen(filename) + 1 + 4);
|
pubkeyfile = malloc(klen);
|
||||||
if (pubkeyfile == NULL) {
|
if (pubkeyfile == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
leave_function();
|
leave_function();
|
||||||
return SSH_AUTH_ERROR;
|
return SSH_AUTH_ERROR;
|
||||||
}
|
}
|
||||||
sprintf(pubkeyfile, "%s.pub", filename);
|
snprintf(pubkeyfile, klen, "%s.pub", filename);
|
||||||
|
|
||||||
pubkey = publickey_from_file(session, pubkeyfile, &type);
|
pubkey = publickey_from_file(session, pubkeyfile, &type);
|
||||||
if (pubkey == NULL) {
|
if (pubkey == NULL) {
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user