mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
legacy: Use snprintf instead of sprintf.
Found by Coverity.
This commit is contained in:
@@ -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) {
|
||||||
|
Reference in New Issue
Block a user