Closed
Bug 341124
Opened 20 years ago
Closed 16 years ago
Coverity 522 Callers of mp_unsigned_octet_size don't check for negative return value
Categories
(NSS :: Libraries, defect, P3)
Tracking
(Not tracked)
RESOLVED
FIXED
3.13
People
(Reporter: nelson, Assigned: timeless)
Details
(Keywords: coverity, Whiteboard: [CID 522 523] FIPS)
Attachments
(1 file, 2 obsolete files)
|
3.81 KB,
patch
|
timeless
:
review+
nelson
:
superreview+
|
Details | Diff | Splinter Review |
mp_unsigned_octet_size can return a negative value.
Freebl functions DH_Derive and KEA_Derive call it and do not check its
return value for a negative number before using it.
Coverity thinks they should
| Reporter | ||
Updated•20 years ago
|
Priority: -- → P3
Whiteboard: [CID 522 523]
| Reporter | ||
Updated•19 years ago
|
Target Milestone: 3.11.3 → ---
| Reporter | ||
Comment 2•16 years ago
|
||
Code is inside the FIPS boundary
Whiteboard: [CID 522 523] → [CID 522 523] FIPS
| Reporter | ||
Comment 3•16 years ago
|
||
Comment on attachment 430921 [details] [diff] [review]
proposal
> CHECK_MPI_OK( mp_exptmod(&Yb, &Xa, &p, &ZZ) );
> /* number of bytes in the derived secret */
> len = mp_unsigned_octet_size(&ZZ);
>+ if (len <= 0) {
>+ PORT_SetError(SEC_ERROR_INVALID_ARGS);
>+ return SECFailure;
>+ }
Uh, this will cause a leak of all the allocated mp_ints.
Think about going to the "cleanup" label instead.
Attachment #430921 -
Flags: review?(nelson) → review-
Attachment #430921 -
Attachment is obsolete: true
Attachment #431045 -
Flags: review?(nelson)
| Reporter | ||
Comment 5•16 years ago
|
||
Comment on attachment 431045 [details] [diff] [review]
cleanup
I believe this change is correct, so I will give it r+, but I would
like to suggest that you consider a further improvement.
Rather than adding a new variable declaration in every function that
uses the macro MPINT_TO_SECITEM, I'd suggest you embed the
declaration in that macro, e.g. something like this:
> #define MPINT_TO_SECITEM(mp, it, arena) \
>+ do { int mpintLen = mp_unsigned_octet_size(mp); \
>+ if (mpintLen <= 0) {err = MP_RANGE; goto cleanup;} \
>+ SECITEM_AllocItem(arena, (it), mpintLen); \
> if ((it)->data == NULL) {err = MP_MEM; goto cleanup;} \
> err = mp_to_unsigned_octets(mp, (it)->data, (it)->len); \
> if (err < 0) goto cleanup; else err = MP_OKAY; \
>+ } while (0)
Attachment #431045 -
Flags: review?(nelson) → review+
Attachment #431045 -
Attachment is obsolete: true
Attachment #431069 -
Flags: review+
| Reporter | ||
Updated•16 years ago
|
Attachment #431069 -
Flags: superreview+
| Reporter | ||
Updated•16 years ago
|
Target Milestone: --- → 3.13
| Reporter | ||
Comment 7•16 years ago
|
||
Checking in dh.c; new revision: 1.8.8.1; previous revision: 1.8
Checking in secmpi.h; new revision: 1.5.132.1; previous revision: 1.5
Checking in mpi/mpi.c; new revision: 1.45.56.1; previous revision: 1.45
Thanks Timeless
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•