Closed Bug 1257885 Opened 8 years ago Closed 8 years ago

Fix some unchecked return values

Categories

(NSS :: Libraries, defect)

defect
Not set
normal

Tracking

(firefox48 affected)

RESOLVED FIXED
Tracking Status
firefox48 --- affected

People

(Reporter: franziskus, Assigned: franziskus)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1209050, CID 1327927, CID 1327930, CID 1327931, CID 1355453, CID 1355454)

Attachments

(1 file, 1 obsolete file)

Fixing some unchecked return values that coverity found.
Attached patch checkSecItemReturns.patch (obsolete) — Splinter Review
Attachment #8732223 - Flags: review?(ttaubert)
Comment on attachment 8732223 [details] [diff] [review]
checkSecItemReturns.patch

Review of attachment 8732223 [details] [diff] [review]:
-----------------------------------------------------------------

::: cmd/bltest/blapitest.c
@@ +979,5 @@
>  	    break;
>  	}
>  	if (in->data[in->len-1] == '\n') --in->len;
>  	if (in->data[in->len-1] == '\r') --in->len;
> +	CHECKERROR(SECITEM_CopyItem(arena, &input->buf, in), __LINE__);

I'm not sure that using CHECKERROR() is the right thing here, a few lines above we check the return value of SECU_FileToItem() and in that case simply return SECFailure, instead of calling exit() as CHECKERROR() would do. Also problematic though seems that not a single caller of setupIO() checks its return value.

@@ +1062,5 @@
>  
>  void
>  bltestCopyIO(PLArenaPool *arena, bltestIO *dest, bltestIO *src)
>  {
> +    CHECKERROR(SECITEM_CopyItem(arena, &dest->buf, &src->buf), __LINE__);

It might make more sense to have bltestCopyIO() return a SECStatus, its call sites seem to usually check for a failure along the way (rv |= ...) and probably don't expect the program to exit.

::: cmd/crlutil/crlutil.c
@@ +55,5 @@
>              }
>              CERT_DestroyName(certName);
>          }
>  
> +        if (rv != SECSuccess || !derName.len || !derName.data) {

I think we should probably check |rv| separately and print a different error message? SECITEM_CopyItem() would probably only fail when OOM, that shouldn't occur too often when testing.

::: lib/pkcs12/p12dec.c
@@ +63,5 @@
>  	}
>  	pfx->old = PR_TRUE;
> +	rv = SGN_CopyDigestInfo(pfx->poolp, &pfx->macData.safeMac, &pfx->old_safeMac);
> +	if(rv != SECSuccess) {
> +	    PORT_SetError(SEC_ERROR_PKCS12_DECODING_PFX);

This should probably be SEC_ERROR_NO_MEMORY.

@@ +69,5 @@
> +	    return NULL;
> +	}
> +	rv = SECITEM_CopyItem(pfx->poolp, &pfx->macData.macSalt, &pfx->old_macSalt);
> +	if(rv != SECSuccess) {
> +	    PORT_SetError(SEC_ERROR_PKCS12_DECODING_PFX);

SEC_ERROR_NO_MEMORY here too.
Attachment #8732223 - Flags: review?(ttaubert) → feedback+
this should address everything.
Attachment #8732223 - Attachment is obsolete: true
Attachment #8733286 - Flags: review?(ttaubert)
Comment on attachment 8733286 [details] [diff] [review]
checkSecItemReturns.patch

Review of attachment 8733286 [details] [diff] [review]:
-----------------------------------------------------------------

::: cmd/crlutil/crlutil.c
@@ +56,5 @@
>              CERT_DestroyName(certName);
>          }
>  
> +        if (rv != SECSuccess) {
> +            SECU_PrintError(progName, "SECITEM_CopyItem failed, out of memorey");

*memory :)
Attachment #8733286 - Flags: review?(ttaubert) → review+
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.25
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: