diff options
author | Jan Cholasta <jcholast@redhat.com> | 2014-06-03 14:49:56 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-06-18 14:17:50 +0200 |
commit | 26510727739c3e8d14f804568e496b7d7b073964 (patch) | |
tree | ec02d05a0fc9494cfe49214965fbb828d74deacc /src/util/sss_ssh.c | |
parent | 21fc2ea7d4a9944582ffd4d11500faf4bddae835 (diff) | |
download | sssd-26510727739c3e8d14f804568e496b7d7b073964.tar.gz sssd-26510727739c3e8d14f804568e496b7d7b073964.tar.xz sssd-26510727739c3e8d14f804568e496b7d7b073964.zip |
SSH: Allow newline at the end of public key values in LDAP
Resolves:
https://fedorahosted.org/sssd/ticket/2349
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/util/sss_ssh.c')
-rw-r--r-- | src/util/sss_ssh.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/util/sss_ssh.c b/src/util/sss_ssh.c index 86903753d..a6709997a 100644 --- a/src/util/sss_ssh.c +++ b/src/util/sss_ssh.c @@ -152,7 +152,7 @@ sss_ssh_format_pubkey(TALLOC_CTX *mem_ctx, char *blob; char *algo; char *out = NULL; - size_t i; + size_t i, len; tmp_ctx = talloc_new(NULL); if (!tmp_ctx) { @@ -182,21 +182,27 @@ sss_ssh_format_pubkey(TALLOC_CTX *mem_ctx, } else { /* Not a valid public key blob, so this must be a textual public key */ for (i = 0; i < pubkey->data_len; i++) { - if (!pubkey->data[i] || pubkey->data[i] == '\n' || + if (pubkey->data[i] == '\0' || + (pubkey->data[i] == '\n' && i != pubkey->data_len - 1) || pubkey->data[i] == '\r') { ret = EINVAL; goto done; } } - out = talloc_array(mem_ctx, char, pubkey->data_len + 1); - if (!out) { + len = pubkey->data_len; + if (pubkey->data[len - 1] == '\n') { + len--; + } + + out = talloc_array(mem_ctx, char, len + 1); + if (out == NULL) { ret = ENOMEM; goto done; } - memcpy(out, pubkey->data, pubkey->data_len); - out[pubkey->data_len] = 0; + memcpy(out, pubkey->data, len); + out[len] = '\0'; } *result = out; |