Skip to content

Commit

Permalink
Safely handle NULL pointers in PR.c code
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Scheel <[email protected]>
  • Loading branch information
cipherboy committed Sep 30, 2020
1 parent 8350c4e commit 9ff2543
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions org/mozilla/jss/nss/PR.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Java_org_mozilla_jss_nss_PR_Close(JNIEnv *env, jclass clazz, jobject fd, jboolea
return PR_SUCCESS;
}

if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS) {
if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS || real_fd == NULL) {
return PR_FAILURE;
}

Expand Down Expand Up @@ -167,7 +167,7 @@ Java_org_mozilla_jss_nss_PR_Shutdown(JNIEnv *env, jclass clazz, jobject fd,
return PR_SUCCESS;
}

if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS) {
if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS || real_fd == NULL) {
return PR_FAILURE;
}

Expand All @@ -189,7 +189,7 @@ Java_org_mozilla_jss_nss_PR_Read(JNIEnv *env, jclass clazz, jobject fd,
PR_ASSERT(env != NULL && fd != NULL && amount >= 0);
PR_SetError(0, 0);

if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS) {
if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS || real_fd == NULL) {
return NULL;
}

Expand Down Expand Up @@ -257,7 +257,7 @@ Java_org_mozilla_jss_nss_PR_Write(JNIEnv *env, jclass clazz, jobject fd,
PR_ASSERT(env != NULL && fd != NULL);
PR_SetError(0, 0);

if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS) {
if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS || real_fd == NULL) {
return 0;
}

Expand Down Expand Up @@ -299,7 +299,7 @@ Java_org_mozilla_jss_nss_PR_Recv(JNIEnv *env, jclass clazz, jobject fd,
timeout >= 0 && timeout <= UINT32_MAX);
PR_SetError(0, 0);

if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS) {
if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS || real_fd == NULL) {
return NULL;
}

Expand Down Expand Up @@ -334,7 +334,7 @@ Java_org_mozilla_jss_nss_PR_Send(JNIEnv *env, jclass clazz, jobject fd,
timeout >= 0 && timeout <= UINT32_MAX);
PR_SetError(0, 0);

if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS) {
if (JSS_PR_getPRFileDesc(env, fd, &real_fd) != PR_SUCCESS || real_fd == NULL) {
return 0;
}

Expand Down

0 comments on commit 9ff2543

Please sign in to comment.