Closed Bug 454961 Opened 16 years ago Closed 16 years ago

Fix the implementation and use of pr_fgets in signtool

Categories

(NSS :: Tools, defect)

defect
Not set
minor

Tracking

(Not tracked)

RESOLVED FIXED
3.12.2

People

(Reporter: wtc, Assigned: wtc)

References

()

Details

Attachments

(1 file)

Attached patch Proposed patchSplinter Review
signtool has a pr_fgets function, which is the fgets function
implemented using NSPR.  Here is the fgets man page:
http://www.opengroup.org/onlinepubs/009695399/functions/fgets.html

The implementation of pr_fgets doesn't match fgets exactly in
that pr_fgets doesn't return NULL when 'file' is at end-of-file.
Also, the way we use pr_fgets in signtool.c isn't quite right.
First, there is an accidental use of the comma operator:

    while (pr_fgets(buf, CMD_FILE_BUFSIZE, fd), buf && *buf != '\0') {
                                              ^^^^^

Second, we don't need to test *buf != '\0'.  (See the example
code in the fgets man page.)  I believe the *buf != '\0' test
was added to compensate for the incorrect implementation of pr_fgets.
Attachment #338264 - Flags: review?(alexei.volkov.bugs)
Comment on attachment 338264 [details] [diff] [review]
Proposed patch

Patch is correct.
Attachment #338264 - Flags: review?(alexei.volkov.bugs) → review+
I checked in the patch on the NSS trunk (NSS 3.12.2).

Checking in signtool.c;
/cvsroot/mozilla/security/nss/cmd/signtool/signtool.c,v  <--  signtool.c
new revision: 1.15; previous revision: 1.14
done
Checking in util.c;
/cvsroot/mozilla/security/nss/cmd/signtool/util.c,v  <--  util.c
new revision: 1.28; previous revision: 1.27
done
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: