aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-08 22:12:40 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-12 14:45:54 +0200
commit46f22576b0f3e076ae20e6981c01bb1f0f4ae9c9 (patch)
tree84424647c802a6919dee2ac21e3eee647c14f0c3 /src
parent2f8ddc6e653b76668c155ade0f90a347857486e2 (diff)
downloadlibssh-46f22576b0f3e076ae20e6981c01bb1f0f4ae9c9.tar.gz
libssh-46f22576b0f3e076ae20e6981c01bb1f0f4ae9c9.tar.xz
libssh-46f22576b0f3e076ae20e6981c01bb1f0f4ae9c9.zip
legacy: Use snprintf instead of sprintf.
Found by Coverity.
Diffstat (limited to 'src')
-rw-r--r--src/legacy.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/legacy.c b/src/legacy.c
index ba04c79d..6ad4fdc2 100644
--- a/src/legacy.c
+++ b/src/legacy.c
@@ -106,16 +106,17 @@ int ssh_userauth_privatekey_file(ssh_session session,
ssh_private_key privkey = NULL;
int type = 0;
int rc = SSH_AUTH_ERROR;
+ size_t klen = strlen(filename) + 4 + 1;
enter_function();
- pubkeyfile = malloc(strlen(filename) + 1 + 4);
+ pubkeyfile = malloc(klen);
if (pubkeyfile == NULL) {
ssh_set_error_oom(session);
leave_function();
return SSH_AUTH_ERROR;
}
- sprintf(pubkeyfile, "%s.pub", filename);
+ snprintf(pubkeyfile, klen, "%s.pub", filename);
pubkey = publickey_from_file(session, pubkeyfile, &type);
if (pubkey == NULL) {