aboutsummaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorJulien Dessaux2018-08-23 14:07:58 +0200
committerJulien Dessaux2018-08-23 17:41:44 +0200
commit4da77dcb10c74c4f369d731addf19c6a065e0684 (patch)
tree7b98cd7c8680ad6d90a4fcbd27f5020eb433adf5 /src/session.c
parentCode cleaning and added error handling (diff)
downloadbastion-4da77dcb10c74c4f369d731addf19c6a065e0684.tar.gz
bastion-4da77dcb10c74c4f369d731addf19c6a065e0684.tar.bz2
bastion-4da77dcb10c74c4f369d731addf19c6a065e0684.zip
Added address sanitization and fixed found bugs
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/session.c b/src/session.c
index 22d10de..1031f7d 100644
--- a/src/session.c
+++ b/src/session.c
@@ -30,7 +30,7 @@ static int auth_pubkey(ssh_session session, const char *user,
// TODO check for an invite
- ssh_key reference_key = ssh_key_new();
+ ssh_key reference_key;
ssh_pki_import_pubkey_base64(USER_RSA_PUBKEY, SSH_KEYTYPE_RSA, &reference_key); // TODO fetch all pubkeys from db
if (!ssh_key_cmp(pubkey, reference_key, SSH_KEY_CMP_PUBLIC)) {
sdata->authenticated = 1;
@@ -41,8 +41,7 @@ static int auth_pubkey(ssh_session session, const char *user,
return SSH_ERROR;
}
sdata->login_username = malloc(len+1);
- memset(sdata->login_username, 0, len+1);
- strncpy(sdata->login_username, user, len);
+ strncpy(sdata->login_username, user, len+1);
return SSH_AUTH_SUCCESS;
} else {
ssh_key_free(reference_key);