pcsc: fix uninitialized variable and class dtor

master
Andre Puschmann 6 years ago
parent 414e55fafc
commit ad2b5d7635

@ -107,36 +107,36 @@ public:
private: private:
srslte::log *log; srslte::log* log = nullptr;
// User data // User data
uint8_t amf[2]; // 3GPP 33.102 v10.0.0 Annex H uint8_t amf[2] = {}; // 3GPP 33.102 v10.0.0 Annex H
uint8_t op[16]; uint8_t op[16] = {};
uint64_t imsi; uint64_t imsi = 0;
uint64_t imei; uint64_t imei = 0;
uint8_t k[16]; uint8_t k[16] = {};
std::string imsi_str; std::string imsi_str;
std::string imei_str; std::string imei_str;
uint32_t mnc_length; uint32_t mnc_length = 0;
// Security variables // Security variables
uint8_t rand[AKA_RAND_LEN]; uint8_t rand[AKA_RAND_LEN] = {};
uint8_t ck[CK_LEN]; uint8_t ck[CK_LEN] = {};
uint8_t ik[IK_LEN]; uint8_t ik[IK_LEN] = {};
uint8_t ak[AK_LEN]; uint8_t ak[AK_LEN] = {};
uint8_t mac[MAC_LEN]; uint8_t mac[MAC_LEN] = {};
uint8_t autn[AKA_AUTN_LEN]; uint8_t autn[AKA_AUTN_LEN] = {};
uint8_t k_asme[KEY_LEN]; uint8_t k_asme[KEY_LEN] = {};
uint8_t nh[KEY_LEN]; uint8_t nh[KEY_LEN] = {};
uint8_t k_enb[KEY_LEN]; uint8_t k_enb[KEY_LEN] = {};
uint8_t k_enb_star[KEY_LEN]; uint8_t k_enb_star[KEY_LEN] = {};
uint8_t auts[AKA_AUTS_LEN]; uint8_t auts[AKA_AUTS_LEN] = {};
uint32_t current_ncc; uint32_t current_ncc = 0;
bool initiated; bool initiated = false;
// Smartcard sub-class which is a port of the PC/SC smartcard implementation // Smartcard sub-class which is a port of the PC/SC smartcard implementation
// of WPA Supplicant written by Jouni Malinen <j@w1.fi> and licensed under BSD // of WPA Supplicant written by Jouni Malinen <j@w1.fi> and licensed under BSD

@ -25,14 +25,14 @@
#include "srsue/hdr/stack/upper/pcsc_usim.h" #include "srsue/hdr/stack/upper/pcsc_usim.h"
#include "string.h" #include "string.h"
#define CHECK_SIM_PIN 1 #define CHECK_SIM_PIN 0
using namespace srslte; using namespace srslte;
using namespace asn1::rrc; using namespace asn1::rrc;
namespace srsue { namespace srsue {
pcsc_usim::pcsc_usim() : initiated(false) pcsc_usim::pcsc_usim()
{ {
bzero(ck, CK_LEN); bzero(ck, CK_LEN);
bzero(ik, IK_LEN); bzero(ik, IK_LEN);
@ -41,7 +41,10 @@ pcsc_usim::pcsc_usim() : initiated(false)
pcsc_usim::~pcsc_usim() pcsc_usim::~pcsc_usim()
{ {
if (initiated) {
sc.deinit(); sc.deinit();
initiated = false;
}
} }
int pcsc_usim::init(usim_args_t *args, srslte::log *log_) int pcsc_usim::init(usim_args_t *args, srslte::log *log_)
@ -407,7 +410,7 @@ int pcsc_usim::scard::init(usim_args_t *args, srslte::log *log_)
return ret_value; return ret_value;
} }
unsigned long len; unsigned long len = 0;
ret = SCardListReaders(scard_context, NULL, NULL, &len); ret = SCardListReaders(scard_context, NULL, NULL, &len);
if (ret != SCARD_S_SUCCESS) { if (ret != SCARD_S_SUCCESS) {
log->error("SCardListReaders(): %s\n", pcsc_stringify_error(ret)); log->error("SCardListReaders(): %s\n", pcsc_stringify_error(ret));

Loading…
Cancel
Save