From 2d7e06a991f6d03ab2229e85185cd7f0090dc739 Mon Sep 17 00:00:00 2001 From: Wonkyu Kwon Date: Wed, 24 Jul 2013 16:20:52 +0900 Subject: [PATCH] Fix the Prevent problems [model] Redwood [binary_type] AP [customer] Open [issue#] too many [problem] from the Prevent [cause] N/A [solution] Fix the Prevent issue [team] NFC [request] N/A [horizontal_expansion] N/A Change-Id: I8a9633a3546a0ef1f31424febd5733433acdf518 --- client/Reader.cpp | 3 +-- client/Session.cpp | 14 ++++++++++---- client/include/Session.h | 8 ++++---- common/GPARFACL.cpp | 10 ++++++++++ common/include/SessionHelper.h | 12 ++++++++---- server/ServerGDBus.cpp | 14 +++++++++++--- server/ServerResource.cpp | 2 ++ 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/client/Reader.cpp b/client/Reader.cpp index 38e3077..e218553 100644 --- a/client/Reader.cpp +++ b/client/Reader.cpp @@ -43,8 +43,7 @@ namespace smartcard_service_api { _BEGIN(); - if (context == NULL || name == NULL || - strlen(name) == 0 || handle == NULL) + if (context == NULL || handle == NULL) { _ERR("invalid param"); diff --git a/client/Session.cpp b/client/Session.cpp index 63a57d0..e08abd1 100644 --- a/client/Session.cpp +++ b/client/Session.cpp @@ -648,6 +648,8 @@ namespace smartcard_service_api GPOINTER_TO_UINT(handle), (guint)id, var_aid, NULL, &Session::session_open_channel_cb, param); + + result = SCARD_ERROR_OK; #else Message msg; @@ -682,13 +684,15 @@ namespace smartcard_service_api } Channel *Session::openBasicChannelSync(const ByteArray &aid) - throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) + throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) { return openChannelSync(0, aid); } Channel *Session::openBasicChannelSync(const unsigned char *aid, unsigned int length) - throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) + throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) { ByteArray temp(aid, length); @@ -709,13 +713,15 @@ namespace smartcard_service_api } Channel *Session::openLogicalChannelSync(const ByteArray &aid) - throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) + throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) { return openChannelSync(1, aid); } Channel *Session::openLogicalChannelSync(const unsigned char *aid, unsigned int length) - throw (ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) + throw (ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) { ByteArray temp(aid, length); diff --git a/client/include/Session.h b/client/include/Session.h index fdff4fc..69df451 100644 --- a/client/include/Session.h +++ b/client/include/Session.h @@ -87,19 +87,19 @@ namespace smartcard_service_api ErrorIllegalState &, ErrorIllegalParameter &); Channel *openBasicChannelSync(const ByteArray &aid) - throw(ErrorIO &, ErrorIllegalState &, + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length) - throw(ErrorIO &, ErrorIllegalState &, + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); Channel *openLogicalChannelSync(const ByteArray &aid) - throw(ErrorIO &, ErrorIllegalState &, + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length) - throw(ErrorIO &, ErrorIllegalState &, + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &); size_t getChannelCount() const; diff --git a/common/GPARFACL.cpp b/common/GPARFACL.cpp index 018473a..71cb37a 100644 --- a/common/GPARFACL.cpp +++ b/common/GPARFACL.cpp @@ -255,6 +255,11 @@ namespace smartcard_service_api { SimpleTLV tlv(data); + if (rule == NULL) { + _ERR("invalid parameter"); + return; + } + if (tlv.decodeTLV() == true) { switch (tlv.getTag()) @@ -304,6 +309,11 @@ namespace smartcard_service_api static void loadNFCAccessRule(AccessRule *rule, const ByteArray &data) { + if (rule == NULL) { + _ERR("invalid parameter"); + return; + } + rule->setNFCAccessRule(SimpleTLV::getBoolean(data)); } diff --git a/common/include/SessionHelper.h b/common/include/SessionHelper.h index 5d7128a..ead9c47 100644 --- a/common/include/SessionHelper.h +++ b/common/include/SessionHelper.h @@ -74,16 +74,20 @@ namespace smartcard_service_api ErrorIllegalState &, ErrorIllegalParameter &) = 0; virtual Channel *openBasicChannelSync(const ByteArray &aid) - throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) = 0; virtual Channel *openBasicChannelSync(const unsigned char *aid, unsigned int length) - throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) = 0; virtual Channel *openLogicalChannelSync(const ByteArray &aid) - throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) = 0; virtual Channel *openLogicalChannelSync(const unsigned char *aid, unsigned int length) - throw(ErrorIO &, ErrorIllegalState &, ErrorIllegalParameter &, ErrorSecurity &) = 0; + throw(ExceptionBase &, ErrorIO &, ErrorIllegalState &, + ErrorIllegalParameter &, ErrorSecurity &) = 0; }; } /* namespace smartcard_service_api */ diff --git a/server/ServerGDBus.cpp b/server/ServerGDBus.cpp index 7409a19..1f60e1e 100644 --- a/server/ServerGDBus.cpp +++ b/server/ServerGDBus.cpp @@ -133,6 +133,11 @@ namespace smartcard_service_api const gchar *name, const gchar *old_owner, const gchar *new_owner, void *user_data) { + if (name == NULL || old_owner == NULL || new_owner == NULL) { + _ERR("invalid parameter"); + return; + } + if (strlen(new_owner) == 0) { ClientInstance *client; @@ -363,9 +368,12 @@ namespace smartcard_service_api resource.createClient(name, pid); instance = resource.getClient(name); - - /* generate certification hashes */ - instance->generateCertificationHashes(); + if (instance != NULL) { + /* generate certification hashes */ + instance->generateCertificationHashes(); + } else { + _ERR("createClient failed"); + } } if (instance != NULL) { diff --git a/server/ServerResource.cpp b/server/ServerResource.cpp index 549d2c6..1f093a0 100644 --- a/server/ServerResource.cpp +++ b/server/ServerResource.cpp @@ -1507,7 +1507,9 @@ namespace smartcard_service_api addAccessControlList(channel, acl); } else { _ERR("unknown error, 0x%x", -ret); + delete acl; + acl = NULL; } } else { _ERR("alloc failed"); -- 2.7.4