Blame SOURCES/esc-1.1.2-fix3.patch

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