Blame SOURCES/esc-1.1.2-fix3.patch

9b58a7
diff -up ./esc/configure.ac.fix3 ./esc/configure.ac
9b58a7
--- ./esc/configure.ac.fix3	2018-07-30 14:51:37.000000000 -0700
9b58a7
+++ ./esc/configure.ac	2018-10-12 14:06:48.349544811 -0700
9b58a7
@@ -56,8 +56,6 @@ AM_PROG_AR
9b58a7
 AM_SILENT_RULES([yes])
9b58a7
 LT_INIT
9b58a7
 
9b58a7
-SCARD_LIB_NAME="libpcsclite.so.1"
9b58a7
-
9b58a7
 # Versioning
9b58a7
 ESC_MAJOR_VERSION=esc_major_version
9b58a7
 ESC_MINOR_VERSION=esc_minor_version
9b58a7
@@ -75,6 +73,7 @@ GOBJECT_INTROSPECTION_CHECK(1.56.1)
9b58a7
 # Output
9b58a7
 AC_DEFINE([DLL_SUFFIX], ["so"], [Description])
9b58a7
 AC_DEFINE([LINUX], [1], [Description])
9b58a7
+AC_DEFINE([SCARD_LIB_NAME],["libpcsclite.so.1"], [Description])
9b58a7
 AC_SUBST(ESC_CFLAGS)
9b58a7
 AC_SUBST(ESC_LIBS)
9b58a7
 AC_CONFIG_FILES([Makefile src/app/Makefile src/lib/coolkey/Makefile src/lib/nss-http-client/Makefile src/lib/coolkey-mgr/Makefile])
9b58a7
diff -up ./esc/src/app/esc.js.fix3 ./esc/src/app/esc.js
9b58a7
--- ./esc/src/app/esc.js.fix3	2018-10-12 17:59:36.790939337 -0700
9b58a7
+++ ./esc/src/app/esc.js	2018-10-12 19:26:51.847470201 -0700
9b58a7
@@ -44,13 +44,16 @@ const CoolKeyNotify = new Lang.Class({
9b58a7
         this._unique_name = "Unknown";
9b58a7
         this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(CoolKeyNotifyIface, this);
9b58a7
         this._dbusImpl.export(Gio.DBus.session, '/com/jmagne/CoolKeyNotify');
9b58a7
-        this._dbusId = Gio.DBus.session.own_name( 'com.rm5248', Gio.BusNameOwnerFlags.NONE, this._nameAcquired.bind(this), this._nameLost);
9b58a7
+        this._dbusId = Gio.DBus.session.own_name( 'com.rm5248', Gio.BusNameOwnerFlags.NONE, this._nameAcquired.bind(this), this._nameLost.bind(this));
9b58a7
     },
9b58a7
     _nameAcquired: function( name ) {
9b58a7
          this._unique_name = name.unique_name;
9b58a7
          this._client._createCoolKeyMgr(this._unique_name);
9b58a7
     },
9b58a7
     _nameLost: function( name ) {
9b58a7
+         if(this._client._window) {
9b58a7
+             this._client._window.destroy();
9b58a7
+         }
9b58a7
     },
9b58a7
 
9b58a7
     notifyCoolKeyEvent: function(aKeyType, aKeyID, aKeyState, aData, strData) {
9b58a7
@@ -76,6 +79,7 @@ class ESC {
9b58a7
         this._window.present();
9b58a7
     }
9b58a7
     _onStartup() {
9b58a7
+         this.mgr = null;
9b58a7
          this._buildUI();
9b58a7
          this.notify = new CoolKeyNotify(this);
9b58a7
      }
9b58a7
@@ -95,8 +99,10 @@ class ESC {
9b58a7
             this.notify._dbusImpl.unexport();
9b58a7
             this.notify = null;
9b58a7
         }
9b58a7
-        this.mgr.cleanup();
9b58a7
-        this.mgr = null;
9b58a7
+        if(this.mgr) {
9b58a7
+            this.mgr.cleanup();
9b58a7
+            this.mgr = null;
9b58a7
+        }
9b58a7
         this._window.destroy();
9b58a7
     }
9b58a7
   
9b58a7
@@ -212,9 +218,7 @@ class ESC {
9b58a7
 
9b58a7
          if (res == false) {
9b58a7
              this._configFile.set_string("ESC","name","Smart Card Utility");
9b58a7
-             print("attmpeting to create: " + config_name);
9b58a7
              res = this._configFile.save_to_file(config_name); 
9b58a7
-             print("res: " + res);
9b58a7
          } 
9b58a7
      }
9b58a7
 
9b58a7
diff -up ./esc/src/lib/coolkey/cky_card.c.fix3 ./esc/src/lib/coolkey/cky_card.c
9b58a7
--- ./esc/src/lib/coolkey/cky_card.c.fix3	2018-05-03 14:03:07.000000000 -0700
9b58a7
+++ ./esc/src/lib/coolkey/cky_card.c	2018-10-12 14:06:48.350544806 -0700
9b58a7
@@ -139,21 +139,15 @@ typedef struct _SCard {
9b58a7
         goto fail; \
9b58a7
     }
9b58a7
 
9b58a7
-#ifdef WIN32
9b58a7
-#define SCARD_LIB_NAME "winscard.dll"
9b58a7
-#else
9b58a7
-#ifdef MAC
9b58a7
-#define SCARD_LIB_NAME "PCSC.Framework/PCSC"
9b58a7
-#else
9b58a7
 #ifdef LINUX
9b58a7
-#define SCARD_LIB_NAME "libpcsclite.so"
9b58a7
+#ifndef SCARD_LIB_NAME
9b58a7
+#define SCARD_LIB_NAME "libpcsclite.so.1"
9b58a7
 #else
9b58a7
 #ifndef SCARD_LIB_NAME
9b58a7
 #error "define wincard library for this platform"
9b58a7
 #endif
9b58a7
 #endif
9b58a7
 #endif
9b58a7
-#endif
9b58a7
 
9b58a7
 static SCard *
9b58a7
 ckySCard_Init(void)
9b58a7
diff -up ./esc/src/lib/coolkey/CoolKey.cpp.fix3 ./esc/src/lib/coolkey/CoolKey.cpp
9b58a7
diff -up ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix3 ./esc/src/lib/coolkey-mgr/coolkey-api.cpp
9b58a7
--- ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix3	2018-10-12 15:12:59.937348875 -0700
9b58a7
+++ ./esc/src/lib/coolkey-mgr/coolkey-api.cpp	2018-10-12 18:28:34.674060797 -0700
9b58a7
@@ -71,6 +71,12 @@ tokenInfo *coolkey_get_token_info(int ke
9b58a7
     if(tInfo == NULL) {
9b58a7
        exit(1);
9b58a7
     }
9b58a7
+
9b58a7
+    tInfo ->atr = NULL;
9b58a7
+    tInfo->issuerInfo = NULL;
9b58a7
+    tInfo->issuer = NULL;
9b58a7
+    tInfo->issuedTo = NULL;
9b58a7
+    tInfo->status = 0;
9b58a7
     
9b58a7
     coolkey->GetCoolKeyATR(keyType, keyID, &tInfo->atr); 
9b58a7
 
9b58a7
diff -up ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp.fix3 ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp
9b58a7
--- ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp.fix3	2018-10-12 14:22:05.938864628 -0700
9b58a7
+++ ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp	2018-10-12 19:15:26.447926406 -0700
9b58a7
@@ -1053,17 +1053,19 @@ HRESULT rhCoolKey::GetCoolKeyCertInfo(PR
9b58a7
 HRESULT rhCoolKey::GetCoolKeyATR(PRUint32 aKeyType, const char *aKeyID, char **_retval)
9b58a7
 {
9b58a7
     char tBuff[56];
9b58a7
+    if(aKeyID == NULL || _retval == NULL) {
9b58a7
+        return E_FAIL;
9b58a7
+    }
9b58a7
     *_retval  = NULL;
9b58a7
     AutoCoolKey key(aKeyType, aKeyID);
9b58a7
-    char atr[128];
9b58a7
-    HRESULT res =   CoolKeyGetATR(&key, (char *)&atr,sizeof(atr));
9b58a7
-     PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s Attempting to get the key's ATR: Key: %s, ATR  %s. \n",GetTStamp(tBuff,56),aKeyID, (char *) atr));
9b58a7
-    if(res == S_OK)
9b58a7
-    {
9b58a7
-        char *temp =  (char *) PL_strdup(atr);
9b58a7
-        *_retval  = temp;
9b58a7
+    char atr[128] = {};
9b58a7
+    HRESULT res = CoolKeyGetATR(&key, (char *)&atr,sizeof(atr));
9b58a7
+    PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s Attempting to get the key's ATR: Key: %s, ATR  %s. \n",GetTStamp(tBuff,56),aKeyID, (char *) atr));
9b58a7
+
9b58a7
+    if(res == S_OK) {
9b58a7
+         *_retval  =  (char *) PL_strdup(atr);
9b58a7
     }
9b58a7
-      return NS_OK;
9b58a7
+    return res; 
9b58a7
   }
9b58a7
 
9b58a7
 /* string GetCoolKeyTokenName (in unsigned long aKeyType, in string aKeyID); */
9b58a7
@@ -1097,24 +1099,25 @@ HRESULT rhCoolKey::GetCoolKeyTokenName(P
9b58a7
 HRESULT rhCoolKey::GetCoolKeyIssuerInfo(PRUint32 aKeyType, const char *aKeyID, char **_retval)
9b58a7
 {
9b58a7
     char tBuff[56];
9b58a7
+
9b58a7
+    if(aKeyID == NULL || _retval == NULL) {
9b58a7
+        return E_FAIL;
9b58a7
+    }
9b58a7
     *_retval  = NULL;
9b58a7
 
9b58a7
     AutoCoolKey key(aKeyType, aKeyID);
9b58a7
 
9b58a7
-    char issuerInfo[256];
9b58a7
+    char issuerInfo[256] = {};
9b58a7
 
9b58a7
     HRESULT res =  CoolKeyGetIssuerInfo(&key, (char *)&issuerInfo,256);
9b58a7
 
9b58a7
     ::CoolKeyLogMsg( 1, "%s Attempting to get the key's Issuer: Key: %s, Issuer  %s. \n",GetTStamp(tBuff,56),aKeyID, (char *) issuerInfo);
9b58a7
 
9b58a7
-    if(res == S_OK)
9b58a7
-    {
9b58a7
-        char *temp =  (char *) PL_strdup(issuerInfo);
9b58a7
-        *_retval  = temp;
9b58a7
-
9b58a7
+    if(res == S_OK) {
9b58a7
+        *_retval =  (char *) PL_strdup(issuerInfo);
9b58a7
     }
9b58a7
-    return NS_OK;
9b58a7
 
9b58a7
+    return res;
9b58a7
 }
9b58a7
 
9b58a7
 /* void rhGetCoolKeyPolicy (in unsigned long aKeyType, in string aKeyID, out string policy); */
9b58a7
@@ -1153,28 +1156,22 @@ HRESULT rhCoolKey::GetCoolKeyPolicy(PRUi
9b58a7
 HRESULT rhCoolKey::GetCoolKeyUID(PRUint32 aKeyType, const char *aKeyID, char **uid)
9b58a7
 {
9b58a7
     char tBuff[56];
9b58a7
-    if (!aKeyID) {
9b58a7
-        return NS_ERROR_FAILURE;
9b58a7
+    if (aKeyID  == NULL || uid == NULL) {
9b58a7
+        return E_FAIL;
9b58a7
     }
9b58a7
 
9b58a7
     AutoCoolKey key(aKeyType, ( char *)aKeyID);
9b58a7
 
9b58a7
-    char buff[512];
9b58a7
+    char buff[512] = {};
9b58a7
     int bufLength = 512;
9b58a7
-    buff[0] = 0;
9b58a7
    
9b58a7
-    CoolKeyGetUID(&key, (char *) buff, bufLength);
9b58a7
-
9b58a7
-    if(!buff[0])
9b58a7
-    {
9b58a7
-        return NS_OK;
9b58a7
-    }
9b58a7
+    HRESULT res = CoolKeyGetUID(&key, (char *) buff, bufLength);
9b58a7
 
9b58a7
     PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetUID  %s \n",GetTStamp(tBuff,56),(char *) buff));
9b58a7
 
9b58a7
-    char *temp =  (char *) PL_strdup(buff);
9b58a7
-
9b58a7
-    *uid = temp;
9b58a7
+    if(res == S_OK) {
9b58a7
+        char *uid =  (char *) PL_strdup(buff);
9b58a7
+    }
9b58a7
 
9b58a7
     return NS_OK;
9b58a7
 
9b58a7
@@ -1185,32 +1182,25 @@ HRESULT rhCoolKey::GetCoolKeyUID(PRUint3
9b58a7
 HRESULT rhCoolKey::GetCoolKeyIssuedTo(PRUint32 aKeyType, const char *aKeyID, char **issuedTo)
9b58a7
 {
9b58a7
     char tBuff[56];
9b58a7
-    if (!aKeyID) {
9b58a7
-        return NS_ERROR_FAILURE;
9b58a7
+    if (aKeyID == NULL || issuedTo == NULL) {
9b58a7
+        return E_FAIL;
9b58a7
     }
9b58a7
 
9b58a7
+    *issuedTo = NULL;
9b58a7
     AutoCoolKey key(aKeyType, ( char *)aKeyID);
9b58a7
 
9b58a7
-  //  const char *keyName = CoolKeyGetTokenName(&key);
9b58a7
-
9b58a7
-    char buff[512];
9b58a7
+    char buff[512] = {};
9b58a7
     int bufLength = 512;
9b58a7
-    buff[0] = 0;
9b58a7
     
9b58a7
-    CoolKeyGetIssuedTo(&key, (char *) buff, bufLength);
9b58a7
-
9b58a7
-    if(!buff[0])
9b58a7
-    {
9b58a7
-        return NS_OK;
9b58a7
-    }
9b58a7
+    HRESULT res = CoolKeyGetIssuedTo(&key, (char *) buff, bufLength);
9b58a7
 
9b58a7
     PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetIssuedTo  %s \n",GetTStamp(tBuff,56),(char *) buff));
9b58a7
 
9b58a7
-    char *temp =  (char *) PL_strdup(buff);
9b58a7
-
9b58a7
-    *issuedTo = temp;
9b58a7
+    if(res == S_OK) {
9b58a7
+        *issuedTo =  (char *) PL_strdup(buff);
9b58a7
+    }
9b58a7
 
9b58a7
-    return NS_OK;
9b58a7
+    return res;
9b58a7
 
9b58a7
 }
9b58a7
 
9b58a7
@@ -1218,32 +1208,24 @@ HRESULT rhCoolKey::GetCoolKeyIssuedTo(PR
9b58a7
 HRESULT rhCoolKey::GetCoolKeyIssuer(PRUint32 aKeyType, const char *aKeyID, char **issuer)
9b58a7
 {
9b58a7
     char tBuff[56];
9b58a7
-    if (!aKeyID) {
9b58a7
-        return NS_ERROR_FAILURE;
9b58a7
+    if (!aKeyID || !issuer) {
9b58a7
+        return E_FAIL;
9b58a7
     }
9b58a7
 
9b58a7
     AutoCoolKey key(aKeyType, ( char *)aKeyID);
9b58a7
 
9b58a7
-  //  const char *keyName = CoolKeyGetTokenName(&key);
9b58a7
-
9b58a7
-    char buff[512];
9b58a7
+    char buff[512] =  {};
9b58a7
     int bufLength = 512;
9b58a7
-    buff[0] = 0;
9b58a7
    
9b58a7
-    CoolKeyGetIssuer(&key, (char *) buff, bufLength);
9b58a7
-
9b58a7
-    if(!buff[0])
9b58a7
-    {
9b58a7
-        return NS_OK;
9b58a7
-    }
9b58a7
+    HRESULT res = CoolKeyGetIssuer(&key, (char *) buff, bufLength);
9b58a7
 
9b58a7
     PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetIssuer  %s \n",GetTStamp(tBuff,56),(char *) buff));
9b58a7
 
9b58a7
-    char *temp =  (char *) PL_strdup(buff);
9b58a7
-
9b58a7
-    *issuer = temp;
9b58a7
+    if(res == S_OK) {
9b58a7
+        *issuer =  (char *) PL_strdup(buff);
9b58a7
+    }
9b58a7
 
9b58a7
-    return NS_OK;
9b58a7
+    return res;
9b58a7
 
9b58a7
 }
9b58a7
 
9b58a7
diff -up ./esc/src/lib/coolkey-mgr/rhCoolKey.h.fix3 ./esc/src/lib/coolkey-mgr/rhCoolKey.h