summaryrefslogtreecommitdiff
path: root/esc-1.1.2-fix3.patch
blob: 579156f3e5fb651b90c3c8bd79753625b3fb30d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
diff -up ./esc/configure.ac.fix3 ./esc/configure.ac
--- ./esc/configure.ac.fix3	2018-07-30 14:51:37.000000000 -0700
+++ ./esc/configure.ac	2018-10-12 14:06:48.349544811 -0700
@@ -56,8 +56,6 @@ AM_PROG_AR
 AM_SILENT_RULES([yes])
 LT_INIT
 
-SCARD_LIB_NAME="libpcsclite.so.1"
-
 # Versioning
 ESC_MAJOR_VERSION=esc_major_version
 ESC_MINOR_VERSION=esc_minor_version
@@ -75,6 +73,7 @@ GOBJECT_INTROSPECTION_CHECK(1.56.1)
 # Output
 AC_DEFINE([DLL_SUFFIX], ["so"], [Description])
 AC_DEFINE([LINUX], [1], [Description])
+AC_DEFINE([SCARD_LIB_NAME],["libpcsclite.so.1"], [Description])
 AC_SUBST(ESC_CFLAGS)
 AC_SUBST(ESC_LIBS)
 AC_CONFIG_FILES([Makefile src/app/Makefile src/lib/coolkey/Makefile src/lib/nss-http-client/Makefile src/lib/coolkey-mgr/Makefile])
diff -up ./esc/src/app/esc.js.fix3 ./esc/src/app/esc.js
--- ./esc/src/app/esc.js.fix3	2018-10-12 17:59:36.790939337 -0700
+++ ./esc/src/app/esc.js	2018-10-12 19:26:51.847470201 -0700
@@ -44,13 +44,16 @@ const CoolKeyNotify = new Lang.Class({
         this._unique_name = "Unknown";
         this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(CoolKeyNotifyIface, this);
         this._dbusImpl.export(Gio.DBus.session, '/com/jmagne/CoolKeyNotify');
-        this._dbusId = Gio.DBus.session.own_name( 'com.rm5248', Gio.BusNameOwnerFlags.NONE, this._nameAcquired.bind(this), this._nameLost);
+        this._dbusId = Gio.DBus.session.own_name( 'com.rm5248', Gio.BusNameOwnerFlags.NONE, this._nameAcquired.bind(this), this._nameLost.bind(this));
     },
     _nameAcquired: function( name ) {
          this._unique_name = name.unique_name;
          this._client._createCoolKeyMgr(this._unique_name);
     },
     _nameLost: function( name ) {
+         if(this._client._window) {
+             this._client._window.destroy();
+         }
     },
 
     notifyCoolKeyEvent: function(aKeyType, aKeyID, aKeyState, aData, strData) {
@@ -76,6 +79,7 @@ class ESC {
         this._window.present();
     }
     _onStartup() {
+         this.mgr = null;
          this._buildUI();
          this.notify = new CoolKeyNotify(this);
      }
@@ -95,8 +99,10 @@ class ESC {
             this.notify._dbusImpl.unexport();
             this.notify = null;
         }
-        this.mgr.cleanup();
-        this.mgr = null;
+        if(this.mgr) {
+            this.mgr.cleanup();
+            this.mgr = null;
+        }
         this._window.destroy();
     }
   
@@ -212,9 +218,7 @@ class ESC {
 
          if (res == false) {
              this._configFile.set_string("ESC","name","Smart Card Utility");
-             print("attmpeting to create: " + config_name);
              res = this._configFile.save_to_file(config_name); 
-             print("res: " + res);
          } 
      }
 
diff -up ./esc/src/lib/coolkey/cky_card.c.fix3 ./esc/src/lib/coolkey/cky_card.c
--- ./esc/src/lib/coolkey/cky_card.c.fix3	2018-05-03 14:03:07.000000000 -0700
+++ ./esc/src/lib/coolkey/cky_card.c	2018-10-12 14:06:48.350544806 -0700
@@ -139,21 +139,15 @@ typedef struct _SCard {
         goto fail; \
     }
 
-#ifdef WIN32
-#define SCARD_LIB_NAME "winscard.dll"
-#else
-#ifdef MAC
-#define SCARD_LIB_NAME "PCSC.Framework/PCSC"
-#else
 #ifdef LINUX
-#define SCARD_LIB_NAME "libpcsclite.so"
+#ifndef SCARD_LIB_NAME
+#define SCARD_LIB_NAME "libpcsclite.so.1"
 #else
 #ifndef SCARD_LIB_NAME
 #error "define wincard library for this platform"
 #endif
 #endif
 #endif
-#endif
 
 static SCard *
 ckySCard_Init(void)
diff -up ./esc/src/lib/coolkey/CoolKey.cpp.fix3 ./esc/src/lib/coolkey/CoolKey.cpp
diff -up ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix3 ./esc/src/lib/coolkey-mgr/coolkey-api.cpp
--- ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix3	2018-10-12 15:12:59.937348875 -0700
+++ ./esc/src/lib/coolkey-mgr/coolkey-api.cpp	2018-10-12 18:28:34.674060797 -0700
@@ -71,6 +71,12 @@ tokenInfo *coolkey_get_token_info(int ke
     if(tInfo == NULL) {
        exit(1);
     }
+
+    tInfo ->atr = NULL;
+    tInfo->issuerInfo = NULL;
+    tInfo->issuer = NULL;
+    tInfo->issuedTo = NULL;
+    tInfo->status = 0;
     
     coolkey->GetCoolKeyATR(keyType, keyID, &tInfo->atr); 
 
diff -up ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp.fix3 ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp
--- ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp.fix3	2018-10-12 14:22:05.938864628 -0700
+++ ./esc/src/lib/coolkey-mgr/rhCoolKey.cpp	2018-10-12 19:15:26.447926406 -0700
@@ -1053,17 +1053,19 @@ HRESULT rhCoolKey::GetCoolKeyCertInfo(PR
 HRESULT rhCoolKey::GetCoolKeyATR(PRUint32 aKeyType, const char *aKeyID, char **_retval)
 {
     char tBuff[56];
+    if(aKeyID == NULL || _retval == NULL) {
+        return E_FAIL;
+    }
     *_retval  = NULL;
     AutoCoolKey key(aKeyType, aKeyID);
-    char atr[128];
-    HRESULT res =   CoolKeyGetATR(&key, (char *)&atr,sizeof(atr));
-     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));
-    if(res == S_OK)
-    {
-        char *temp =  (char *) PL_strdup(atr);
-        *_retval  = temp;
+    char atr[128] = {};
+    HRESULT res = CoolKeyGetATR(&key, (char *)&atr,sizeof(atr));
+    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));
+
+    if(res == S_OK) {
+         *_retval  =  (char *) PL_strdup(atr);
     }
-      return NS_OK;
+    return res; 
   }
 
 /* string GetCoolKeyTokenName (in unsigned long aKeyType, in string aKeyID); */
@@ -1097,24 +1099,25 @@ HRESULT rhCoolKey::GetCoolKeyTokenName(P
 HRESULT rhCoolKey::GetCoolKeyIssuerInfo(PRUint32 aKeyType, const char *aKeyID, char **_retval)
 {
     char tBuff[56];
+
+    if(aKeyID == NULL || _retval == NULL) {
+        return E_FAIL;
+    }
     *_retval  = NULL;
 
     AutoCoolKey key(aKeyType, aKeyID);
 
-    char issuerInfo[256];
+    char issuerInfo[256] = {};
 
     HRESULT res =  CoolKeyGetIssuerInfo(&key, (char *)&issuerInfo,256);
 
     ::CoolKeyLogMsg( 1, "%s Attempting to get the key's Issuer: Key: %s, Issuer  %s. \n",GetTStamp(tBuff,56),aKeyID, (char *) issuerInfo);
 
-    if(res == S_OK)
-    {
-        char *temp =  (char *) PL_strdup(issuerInfo);
-        *_retval  = temp;
-
+    if(res == S_OK) {
+        *_retval =  (char *) PL_strdup(issuerInfo);
     }
-    return NS_OK;
 
+    return res;
 }
 
 /* void rhGetCoolKeyPolicy (in unsigned long aKeyType, in string aKeyID, out string policy); */
@@ -1153,28 +1156,22 @@ HRESULT rhCoolKey::GetCoolKeyPolicy(PRUi
 HRESULT rhCoolKey::GetCoolKeyUID(PRUint32 aKeyType, const char *aKeyID, char **uid)
 {
     char tBuff[56];
-    if (!aKeyID) {
-        return NS_ERROR_FAILURE;
+    if (aKeyID  == NULL || uid == NULL) {
+        return E_FAIL;
     }
 
     AutoCoolKey key(aKeyType, ( char *)aKeyID);
 
-    char buff[512];
+    char buff[512] = {};
     int bufLength = 512;
-    buff[0] = 0;
    
-    CoolKeyGetUID(&key, (char *) buff, bufLength);
-
-    if(!buff[0])
-    {
-        return NS_OK;
-    }
+    HRESULT res = CoolKeyGetUID(&key, (char *) buff, bufLength);
 
     PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetUID  %s \n",GetTStamp(tBuff,56),(char *) buff));
 
-    char *temp =  (char *) PL_strdup(buff);
-
-    *uid = temp;
+    if(res == S_OK) {
+        char *uid =  (char *) PL_strdup(buff);
+    }
 
     return NS_OK;
 
@@ -1185,32 +1182,25 @@ HRESULT rhCoolKey::GetCoolKeyUID(PRUint3
 HRESULT rhCoolKey::GetCoolKeyIssuedTo(PRUint32 aKeyType, const char *aKeyID, char **issuedTo)
 {
     char tBuff[56];
-    if (!aKeyID) {
-        return NS_ERROR_FAILURE;
+    if (aKeyID == NULL || issuedTo == NULL) {
+        return E_FAIL;
     }
 
+    *issuedTo = NULL;
     AutoCoolKey key(aKeyType, ( char *)aKeyID);
 
-  //  const char *keyName = CoolKeyGetTokenName(&key);
-
-    char buff[512];
+    char buff[512] = {};
     int bufLength = 512;
-    buff[0] = 0;
     
-    CoolKeyGetIssuedTo(&key, (char *) buff, bufLength);
-
-    if(!buff[0])
-    {
-        return NS_OK;
-    }
+    HRESULT res = CoolKeyGetIssuedTo(&key, (char *) buff, bufLength);
 
     PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetIssuedTo  %s \n",GetTStamp(tBuff,56),(char *) buff));
 
-    char *temp =  (char *) PL_strdup(buff);
-
-    *issuedTo = temp;
+    if(res == S_OK) {
+        *issuedTo =  (char *) PL_strdup(buff);
+    }
 
-    return NS_OK;
+    return res;
 
 }
 
@@ -1218,32 +1208,24 @@ HRESULT rhCoolKey::GetCoolKeyIssuedTo(PR
 HRESULT rhCoolKey::GetCoolKeyIssuer(PRUint32 aKeyType, const char *aKeyID, char **issuer)
 {
     char tBuff[56];
-    if (!aKeyID) {
-        return NS_ERROR_FAILURE;
+    if (!aKeyID || !issuer) {
+        return E_FAIL;
     }
 
     AutoCoolKey key(aKeyType, ( char *)aKeyID);
 
-  //  const char *keyName = CoolKeyGetTokenName(&key);
-
-    char buff[512];
+    char buff[512] =  {};
     int bufLength = 512;
-    buff[0] = 0;
    
-    CoolKeyGetIssuer(&key, (char *) buff, bufLength);
-
-    if(!buff[0])
-    {
-        return NS_OK;
-    }
+    HRESULT res = CoolKeyGetIssuer(&key, (char *) buff, bufLength);
 
     PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetIssuer  %s \n",GetTStamp(tBuff,56),(char *) buff));
 
-    char *temp =  (char *) PL_strdup(buff);
-
-    *issuer = temp;
+    if(res == S_OK) {
+        *issuer =  (char *) PL_strdup(buff);
+    }
 
-    return NS_OK;
+    return res;
 
 }
 
diff -up ./esc/src/lib/coolkey-mgr/rhCoolKey.h.fix3 ./esc/src/lib/coolkey-mgr/rhCoolKey.h