]> git.pld-linux.org Git - packages/icedtea8.git/blob - icedtea7-bug-2135.patch
f5940cf567c792ba35d8789eea323be0e55b3af8
[packages/icedtea8.git] / icedtea7-bug-2135.patch
1
2 # HG changeset patch
3 # User andrew
4 # Date 1418148279 0
5 # Node ID 610eb1b5fd0beb4c4cf8918f418eeddf9ff58121
6 # Parent  9ed0bdd5de2a5ebfa5fedb9442ee630b8d63ef0e
7 PR2135: Race condition in SunEC provider with system NSS
8
9 diff -r 9ed0bdd5de2a -r 610eb1b5fd0b make/sun/security/ec/Makefile
10 --- openjdk/jdk/make/sun/security/ec/Makefile   Fri Dec 05 09:52:04 2014 +0000
11 +++ openjdk/jdk/make/sun/security/ec/Makefile   Tue Dec 09 18:04:39 2014 +0000
12 @@ -158,7 +158,8 @@
13    FILES_export = \
14        $(PKGDIR)/ECDHKeyAgreement.java \
15        $(PKGDIR)/ECDSASignature.java \
16 -      $(PKGDIR)/ECKeyPairGenerator.java
17 +      $(PKGDIR)/ECKeyPairGenerator.java \
18 +      $(PKGDIR)/SunEC.java
19  
20    JAVAHFLAGS = -bootclasspath \
21      "$(CLASSDESTDIR)$(CLASSPATH_SEPARATOR)$(CLASSBINDIR)$(JCE_PATH)"
22 diff -r 9ed0bdd5de2a -r 610eb1b5fd0b make/sun/security/ec/mapfile-vers
23 --- openjdk/jdk/make/sun/security/ec/mapfile-vers       Fri Dec 05 09:52:04 2014 +0000
24 +++ openjdk/jdk/make/sun/security/ec/mapfile-vers       Tue Dec 09 18:04:39 2014 +0000
25 @@ -31,6 +31,8 @@
26                 Java_sun_security_ec_ECDSASignature_signDigest;
27                 Java_sun_security_ec_ECDSASignature_verifySignedDigest;
28                 Java_sun_security_ec_ECDHKeyAgreement_deriveKey;
29 +               Java_sun_security_ec_SunEC_initialize;
30 +               Java_sun_security_ec_SunEC_cleanup;
31          local:
32                  *;
33  };
34 diff -r 9ed0bdd5de2a -r 610eb1b5fd0b src/share/classes/sun/security/ec/SunEC.java
35 --- openjdk/jdk/src/share/classes/sun/security/ec/SunEC.java    Fri Dec 05 09:52:04 2014 +0000
36 +++ openjdk/jdk/src/share/classes/sun/security/ec/SunEC.java    Tue Dec 09 18:04:39 2014 +0000
37 @@ -58,6 +58,7 @@
38              AccessController.doPrivileged(new PrivilegedAction<Void>() {
39                  public Void run() {
40                      System.loadLibrary("sunec"); // check for native library
41 +                    initialize();
42                      return null;
43                  }
44              });
45 @@ -81,4 +82,22 @@
46          }
47      }
48  
49 +    /**
50 +     * Cleanup native resources during finalisation.
51 +     */
52 +    @Override
53 +    protected void finalize() {
54 +        cleanup();
55 +    }
56 +
57 +    /**
58 +     * Initialize the native code.
59 +     */
60 +    private static native void initialize();
61 +
62 +    /**
63 +     * Cleanup in the native layer.
64 +     */
65 +    private static native void cleanup();
66 +
67  }
68 diff -r 9ed0bdd5de2a -r 610eb1b5fd0b src/share/native/sun/security/ec/ECC_JNI.cpp
69 --- openjdk/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp    Fri Dec 05 09:52:04 2014 +0000
70 +++ openjdk/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp    Tue Dec 09 18:04:39 2014 +0000
71 @@ -116,13 +116,6 @@
72      params_item.data =
73          (unsigned char *) env->GetByteArrayElements(encodedParams, 0);
74  
75 -#ifdef SYSTEM_NSS
76 -    if (SECOID_Init() != SECSuccess) {
77 -       ThrowException(env, INTERNAL_ERROR);
78 -       goto cleanup;
79 -    }
80 -#endif
81 -
82      // Fill a new ECParams using the supplied OID
83      if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
84          /* bad curve OID */
85 @@ -178,11 +171,6 @@
86          if (params_item.data) {
87              env->ReleaseByteArrayElements(encodedParams,
88                  (jbyte *) params_item.data, JNI_ABORT);
89 -#ifdef SYSTEM_NSS
90 -           if (SECOID_Shutdown() != SECSuccess) {
91 -               ThrowException(env, INTERNAL_ERROR);
92 -           }
93 -#endif
94          }
95  
96          if (ecparams) {
97 @@ -246,13 +234,6 @@
98      params_item.data =
99          (unsigned char *) env->GetByteArrayElements(encodedParams, 0);
100  
101 -#ifdef SYSTEM_NSS
102 -    if (SECOID_Init() != SECSuccess) {
103 -       ThrowException(env, INTERNAL_ERROR);
104 -       goto cleanup;
105 -    }
106 -#endif
107 -
108      // Fill a new ECParams using the supplied OID
109      if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
110          /* bad curve OID */
111 @@ -294,11 +275,6 @@
112          if (params_item.data) {
113              env->ReleaseByteArrayElements(encodedParams,
114                  (jbyte *) params_item.data, JNI_ABORT);
115 -#ifdef SYSTEM_NSS
116 -           if (SECOID_Shutdown() != SECSuccess) {
117 -               ThrowException(env, INTERNAL_ERROR);
118 -           }
119 -#endif
120          }
121  
122          if (privKey.privateValue.data) {
123 @@ -367,13 +343,6 @@
124      params_item.data =
125          (unsigned char *) env->GetByteArrayElements(encodedParams, 0);
126  
127 -#ifdef SYSTEM_NSS
128 -    if (SECOID_Init() != SECSuccess) {
129 -       ThrowException(env, INTERNAL_ERROR);
130 -       goto cleanup;
131 -    }
132 -#endif
133 -
134      // Fill a new ECParams using the supplied OID
135      if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
136          /* bad curve OID */
137 @@ -397,11 +366,6 @@
138          if (params_item.data) {
139              env->ReleaseByteArrayElements(encodedParams,
140                  (jbyte *) params_item.data, JNI_ABORT);
141 -#ifdef SYSTEM_NSS
142 -           if (SECOID_Shutdown() != SECSuccess) {
143 -               ThrowException(env, INTERNAL_ERROR);
144 -           }
145 -#endif
146         }
147  
148          if (pubKey.publicValue.data)
149 @@ -451,13 +415,6 @@
150      params_item.data =
151          (unsigned char *) env->GetByteArrayElements(encodedParams, 0);
152  
153 -#ifdef SYSTEM_NSS
154 -    if (SECOID_Init() != SECSuccess) {
155 -       ThrowException(env, INTERNAL_ERROR);
156 -       goto cleanup;
157 -    }
158 -#endif
159 -
160      // Fill a new ECParams using the supplied OID
161      if (EC_DecodeParams(&params_item, &ecparams, 0) != SECSuccess) {
162          /* bad curve OID */
163 @@ -499,11 +456,6 @@
164          if (params_item.data) {
165              env->ReleaseByteArrayElements(encodedParams,
166                  (jbyte *) params_item.data, JNI_ABORT);
167 -#ifdef SYSTEM_NSS
168 -           if (SECOID_Shutdown() != SECSuccess) {
169 -               ThrowException(env, INTERNAL_ERROR);
170 -           }
171 -#endif
172         }
173  
174          if (ecparams)
175 @@ -513,4 +465,26 @@
176      return jSecret;
177  }
178  
179 +JNIEXPORT void
180 +JNICALL Java_sun_security_ec_SunEC_initialize
181 +  (JNIEnv *env, jclass UNUSED(clazz))
182 +{
183 +#ifdef SYSTEM_NSS
184 +    if (SECOID_Init() != SECSuccess) {
185 +       ThrowException(env, INTERNAL_ERROR);
186 +    }
187 +#endif
188 +}
189 +
190 +JNIEXPORT void
191 +JNICALL Java_sun_security_ec_SunEC_cleanup
192 +  (JNIEnv *env, jclass UNUSED(clazz))
193 +{
194 +#ifdef SYSTEM_NSS
195 +    if (SECOID_Shutdown() != SECSuccess) {
196 +       ThrowException(env, INTERNAL_ERROR);
197 +    }
198 +#endif
199 +}
200 +
201  } /* extern "C" */
202
This page took 0.029356 seconds and 2 git commands to generate.