Closed
Bug 136804
Opened 22 years ago
Closed 22 years ago
certutil -A crashes unless -i argument is given
Categories
(NSS :: Tools, defect, P1)
Tracking
(Not tracked)
RESOLVED
FIXED
3.6
People
(Reporter: nelson, Assigned: bishakhabanerjee)
References
Details
Attachments
(1 file)
1.12 KB,
patch
|
Details | Diff | Splinter Review |
If you run the certutil -A command to add a cert to a db, and you don't specify -i to open an input file, then it crashes because inFile is NULL instead of being PR_STDIN. I think there used to be some code that set infile to PR_STDIN if no -i argument was given, but now certutil doesn't seem to contain code to do that. I reproduced this using these steps: 1. create a new certDB in directory ./tmp certutil -N -d tmp 2. attempt to add a cert to the db using an RFC 1113 format file on stdin. certutil -A -d tmp -n foo -a -t "" < /tmp/foocert.txt result: segv stack at crash is: PR_GetOpenFileInfo(PRFileDesc * 0x00000000, PRFileInfo * 0x0012fe10) line 166 + 11 bytes SECU_FileToItem(SECItemStr * 0x0012fe40, PRFileDesc * 0x00000000) line 545 + 14 bytes SECU_ReadDERFromFile(SECItemStr * 0x0012fe80, PRFileDesc * 0x00000000, int 0x00000001) line 626 + 13 bytes AddCert(PK11SlotInfoStr * 0x0051fe48, NSSTrustDomainStr * 0x00519430, char * 0x00494538, char * 0x004944b9, PRFileDesc * 0x00000000, int 0x00000001, int 0x00000000, void * 0x0012fef8) line 285 + 17 bytes main(int 0x00000009, char * * 0x00494440) line 2808 + 49 bytes You can clearly see all the null PRFileDesc pointers there. Using -i works around this.
Comment 1•22 years ago
|
||
It should be easy to fix the crash if -A is specified without -i. crlutil has a similar logic (in cmd/crlutil/crlutil.c) to ensure that -I must be specified with -i: if (importCRL && !inFile) Usage (progName); As for whether certutil should read from PR_STDIN if no input file is specified, I'll let you decide. I checked NSS 3.3.2 and found that it does not set inFile to PR_STDIN either if no -i argument is given. So the code to do that may have been lost for several releases or may not have existed before.
Assignee: wtc → bishakhabanerjee
Priority: -- → P2
Reporter | ||
Comment 2•22 years ago
|
||
The documented behavior of cerutil -A is that it reads from stdin unless the -i argument is given. Therefore, the correct behavior would be to set inFile to PR_STDIN if -i is not specified. A trivial one-line fix would be to initialize inFile with PR_STDIN rather than with NULL.
Comment 3•22 years ago
|
||
Changed the QA contact to Bishakha.
QA Contact: sonja.mirtitsch → bishakhabanerjee
Updated•22 years ago
|
Priority: P2 → P1
Target Milestone: --- → 3.6
Comment 4•22 years ago
|
||
*** Bug 166633 has been marked as a duplicate of this bug. ***
Comment 5•22 years ago
|
||
This is the fix that Nelson suggested in comment #2. I added two assertions to catch errors (inFile should be the certreqfile and the certfile at those two places).
Comment 6•22 years ago
|
||
Fix checked in.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•