Closed Bug 337080 Opened 18 years ago Closed 18 years ago

Coverity 681, dead code in mozilla/security/nss/lib/ssl/ssl3con.c

Categories

(NSS :: Libraries, defect, P3)

3.11
defect

Tracking

(Not tracked)

RESOLVED FIXED
3.11.2

People

(Reporter: jonsmirl, Assigned: nelson)

Details

(Keywords: coverity, Whiteboard: [CID 160 681 853 952])

Attachments

(2 files)

Clean up error path to remove dead code. So far I have found one dead code flag that was a bug. If these are cleaned Coverity won't keep hitting them.

diff -u -r1.76 ssl3con.c
--- security/nss/lib/ssl/ssl3con.c      18 Nov 2005 01:25:20 -0000      1.76
+++ security/nss/lib/ssl/ssl3con.c      8 May 2006 03:52:30 -0000
@@ -1849,16 +1849,12 @@
            PORT_Assert(rv == SECSuccess && cipherBytesPart2 == p2Len);
            if (rv != SECSuccess || cipherBytesPart2 != p2Len) {
                PORT_SetError(SSL_ERROR_ENCRYPTION_FAILURE);
-                   goto spec_locked_loser;
-               }
+spec_locked_loser:
+               ssl_ReleaseSpecReadLock(ss);
+               return SECFailure;
+           }
            cipherBytes += cipherBytesPart2;
        }
-       if (rv != SECSuccess) {
-           ssl_MapLowLevelError(SSL_ERROR_ENCRYPTION_FAILURE);
-spec_locked_loser:
-           ssl_ReleaseSpecReadLock(ss);
-           return SECFailure;
-       }
        PORT_Assert(cipherBytes <= MAX_FRAGMENT_LENGTH + 1024);

        /*
Severity: normal → trivial
Priority: -- → P3
Attachment #221256 - Flags: review?(wtchang)
Comment on attachment 221256 [details] [diff] [review]
Clean up error path

There's no incorrect behavior here, nothing that produces wrong results.  
Moving the common code into one of the cases that invokes it doesn't make the code clearer or more maintainable.
Attachment #221256 - Flags: review?(wtchang) → review-
These two lines are unreachable.

-       if (rv != SECSuccess) {
-           ssl_MapLowLevelError(SSL_ERROR_ENCRYPTION_FAILURE);

When you remove them it makes sense to move the label and the code.
(In reply to comment #3)
> These two lines are unreachable.
> 
> -       if (rv != SECSuccess) {
> -           ssl_MapLowLevelError(SSL_ERROR_ENCRYPTION_FAILURE);

try replacing them with 
> +       if (0) {
Assignee: nobody → nelson
Attached patch YA alternativeSplinter Review
Alexei, please review
Attachment #222467 - Flags: review?(alexei.volkov.bugs)
Comment on attachment 222467 [details] [diff] [review]
YA alternative

r=alexei.volkov.bugs
Attachment #222467 - Flags: review?(alexei.volkov.bugs) → review+
Checking in ssl/ssl3con.c; new revision: 1.90; previous revision: 1.89
Checking in ssl3con.c; new revision: 1.76.2.12; previous revision: 1.76.2.11
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
CID 160 & 681
Whiteboard: [CID 160 681]
Also CID 853
Whiteboard: [CID 160 681] → [CID 160 681 853]
Also CID 952
Whiteboard: [CID 160 681 853] → [CID 160 681 853 952]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: