-
Bug
-
Resolution: Fixed
-
P4
-
None
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8048399 | 8u25 | Ivan Gerasimov | P4 | Resolved | Fixed | b05 |
JDK-8044285 | 8u20 | Ivan Gerasimov | P4 | Resolved | Fixed | b20 |
JDK-8053658 | emb-8u26 | Ivan Gerasimov | P4 | Resolved | Fixed | b17 |
JDK-8044286 | 7u80 | Ivan Gerasimov | P4 | Resolved | Fixed | b01 |
JDK-8061037 | 7u79 | Ivan Gerasimov | P4 | Resolved | Fixed | b01 |
JDK-8057361 | 7u76 | Ivan Gerasimov | P4 | Resolved | Fixed | b01 |
There are a few issues with the native memory allocation in share/native/sun/security/smartcardio/pcsc.c:
1)
readerState = calloc(readers, sizeof(SCARD_READERSTATE));
if (readerState == NULL) {
throwOutOfMemoryError(env, NULL);
calloc() can return NULL due to readers be zero.
In this case OOM would be confusing.
2)
for (i = 0; i < readers; i++) {
free((char *)readerState[i].szReader);
}
We can get here upon an error, so readerState[i].szReader may not be initialized.
3)
mszReaders = malloc(size);
if (mszReaders == NULL) {
throwOutOfMemoryError(env, NULL);
return NULL;
}
If size happens to be zero, we'll get a confusing OOM.
4)
tab = (char **)malloc(cnt * sizeof(char *));
if (tab == NULL) {
throwOutOfMemoryError(env, NULL);
return NULL;
}
Again, we can get NULL from malloc, if cnt == 0.
1)
readerState = calloc(readers, sizeof(SCARD_READERSTATE));
if (readerState == NULL) {
throwOutOfMemoryError(env, NULL);
calloc() can return NULL due to readers be zero.
In this case OOM would be confusing.
2)
for (i = 0; i < readers; i++) {
free((char *)readerState[i].szReader);
}
We can get here upon an error, so readerState[i].szReader may not be initialized.
3)
mszReaders = malloc(size);
if (mszReaders == NULL) {
throwOutOfMemoryError(env, NULL);
return NULL;
}
If size happens to be zero, we'll get a confusing OOM.
4)
tab = (char **)malloc(cnt * sizeof(char *));
if (tab == NULL) {
throwOutOfMemoryError(env, NULL);
return NULL;
}
Again, we can get NULL from malloc, if cnt == 0.
- backported by
-
JDK-8044285 (smartcardio) Native memory should be handled more accurately
-
- Resolved
-
-
JDK-8044286 (smartcardio) Native memory should be handled more accurately
-
- Resolved
-
-
JDK-8048399 (smartcardio) Native memory should be handled more accurately
-
- Resolved
-
-
JDK-8053658 (smartcardio) Native memory should be handled more accurately
-
- Resolved
-
-
JDK-8057361 (smartcardio) Native memory should be handled more accurately
-
- Resolved
-
-
JDK-8061037 (smartcardio) Native memory should be handled more accurately
-
- Resolved
-
(1 backported by)