Blame SOURCES/esc-1.1.2-fix3.patch

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