The default bug view has changed. See this FAQ.

Fix the implementation and use of pr_fgets in signtool

RESOLVED FIXED in 3.12.2

Status

NSS
Tools
--
minor
RESOLVED FIXED
9 years ago
9 years ago

People

(Reporter: Wan-Teh Chang, Assigned: Wan-Teh Chang)

Tracking

unspecified
3.12.2

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Assignee)

Description

9 years ago
Created attachment 338264 [details] [diff] [review]
Proposed patch

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 1

9 years ago
Comment on attachment 338264 [details] [diff] [review]
Proposed patch

Patch is correct.
Attachment #338264 - Flags: review?(alexei.volkov.bugs) → review+
(Assignee)

Comment 2

9 years ago
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
Last Resolved: 9 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.