=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/Attic/scard.c,v retrieving revision 1.29 retrieving revision 1.29.6.2 diff -u -r1.29 -r1.29.6.2 --- src/usr.bin/ssh/Attic/scard.c 2004/05/08 00:21:31 1.29 +++ src/usr.bin/ssh/Attic/scard.c 2006/11/08 00:44:05 1.29.6.2 @@ -1,3 +1,4 @@ +/* $OpenBSD: scard.c,v 1.29.6.2 2006/11/08 00:44:05 brad Exp $ */ /* * Copyright (c) 2001 Markus Friedl. All rights reserved. * @@ -23,15 +24,17 @@ */ #ifdef SMARTCARD -#include "includes.h" -RCSID("$OpenBSD: scard.c,v 1.29 2004/05/08 00:21:31 djm Exp $"); +#include + #include + #include +#include +#include "xmalloc.h" #include "key.h" #include "log.h" -#include "xmalloc.h" #include "misc.h" #include "scard.h" @@ -125,7 +128,7 @@ if (status == SCARD_ERROR_NOCARD) { return SCARD_ERROR_NOCARD; } - if (status < 0 ) { + if (status < 0) { error("sc_open failed"); return status; } @@ -215,7 +218,7 @@ olen = len = sw = 0; if (sc_fd < 0) { status = sc_init(); - if (status < 0 ) + if (status < 0) goto err; } if (padding != RSA_PKCS1_PADDING) @@ -255,7 +258,7 @@ len = sw = 0; if (sc_fd < 0) { status = sc_init(); - if (status < 0 ) + if (status < 0) goto err; } if (padding != RSA_PKCS1_PADDING) @@ -378,23 +381,25 @@ key_free(k); return NULL; } - if (status < 0 ) { + if (status < 0) { error("sc_read_pubkey failed"); key_free(k); return NULL; } - keys = xmalloc((nkeys+1) * sizeof(Key *)); + keys = xcalloc((nkeys+1), sizeof(Key *)); n = key_new(KEY_RSA1); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[0] = n; n = key_new(KEY_RSA); - BN_copy(n->rsa->n, k->rsa->n); - BN_copy(n->rsa->e, k->rsa->e); + if ((BN_copy(n->rsa->n, k->rsa->n) == NULL) || + (BN_copy(n->rsa->e, k->rsa->e) == NULL)) + fatal("sc_get_keys: BN_copy failed"); RSA_set_method(n->rsa, sc_get_rsa()); n->flags |= KEY_FLAG_EXT; keys[1] = n;