1
1

keys: Fixed issues reported by cppcheck.

Этот коммит содержится в:
Oliver Stöneberg 2011-04-11 11:06:32 +02:00 коммит произвёл Andreas Schneider
родитель 7150cabafa
Коммит 46475dfa2f
2 изменённых файлов: 17 добавлений и 15 удалений

Просмотреть файл

@ -720,8 +720,6 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
(void *) passphrase, NULL);
}
fclose(file);
if (!valid) {
ssh_set_error(session, SSH_FATAL, "Parsing private key %s", filename);
#elif defined HAVE_LIBCRYPTO
@ -735,12 +733,12 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
dsa = PEM_read_DSAPrivateKey(file, NULL, NULL, (void *) passphrase);
}
fclose(file);
if (dsa == NULL) {
ssh_set_error(session, SSH_FATAL,
"Parsing private key %s: %s",
filename, ERR_error_string(ERR_get_error(), NULL));
#endif
fclose(file);
return NULL;
}
break;
@ -760,8 +758,6 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
(void *) passphrase, NULL);
}
fclose(file);
if (!valid) {
ssh_set_error(session,SSH_FATAL, "Parsing private key %s", filename);
#elif defined HAVE_LIBCRYPTO
@ -775,13 +771,12 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
rsa = PEM_read_RSAPrivateKey(file, NULL, NULL, (void *) passphrase);
}
fclose(file);
if (rsa == NULL) {
ssh_set_error(session, SSH_FATAL,
"Parsing private key %s: %s",
filename, ERR_error_string(ERR_get_error(),NULL));
#endif
fclose(file);
return NULL;
}
break;
@ -791,6 +786,8 @@ ssh_private_key privatekey_from_file(ssh_session session, const char *filename,
return NULL;
} /* switch */
fclose(file);
privkey = malloc(sizeof(struct ssh_private_key_struct));
if (privkey == NULL) {
#ifdef HAVE_LIBGCRYPT
@ -850,20 +847,19 @@ ssh_private_key _privatekey_from_file(void *session, const char *filename,
#ifdef HAVE_LIBGCRYPT
valid = read_dsa_privatekey(file, &dsa, NULL, NULL, NULL);
fclose(file);
if (!valid) {
ssh_set_error(session, SSH_FATAL, "Parsing private key %s", filename);
#elif defined HAVE_LIBCRYPTO
dsa = PEM_read_DSAPrivateKey(file, NULL, NULL, NULL);
fclose(file);
if (dsa == NULL) {
ssh_set_error(session, SSH_FATAL,
"Parsing private key %s: %s",
filename, ERR_error_string(ERR_get_error(), NULL));
#else
{
#endif
fclose(file);
return NULL;
}
break;
@ -871,28 +867,30 @@ ssh_private_key _privatekey_from_file(void *session, const char *filename,
#ifdef HAVE_LIBGCRYPT
valid = read_rsa_privatekey(file, &rsa, NULL, NULL, NULL);
fclose(file);
if (!valid) {
ssh_set_error(session, SSH_FATAL, "Parsing private key %s", filename);
#elif defined HAVE_LIBCRYPTO
rsa = PEM_read_RSAPrivateKey(file, NULL, NULL, NULL);
fclose(file);
if (rsa == NULL) {
ssh_set_error(session, SSH_FATAL,
"Parsing private key %s: %s",
filename, ERR_error_string(ERR_get_error(), NULL));
#else
{
#endif
fclose(file);
return NULL;
}
break;
default:
fclose(file);
ssh_set_error(session, SSH_FATAL, "Invalid private key type %d", type);
return NULL;
}
fclose(file);
privkey = malloc(sizeof(struct ssh_private_key_struct));
if (privkey == NULL) {
#ifdef HAVE_LIBGCRYPT

Просмотреть файл

@ -597,7 +597,9 @@ error:
ssh_string_free(n);
return rc;
#if defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBCRYPTO)
}
#endif
#ifdef HAVE_LIBGCRYPT
static int rsa_public_to_string(gcry_sexp_t key, ssh_buffer buffer) {
@ -665,7 +667,9 @@ error:
ssh_string_free(n);
return rc;
#if defined(HAVE_LIBGCRYPT) || defined(HAVE_LIBCRYPTO)
}
#endif
/**
* @brief Convert a public_key object into a a SSH string.