Closed Bug 307293 Opened 17 years ago Closed 17 years ago
Tag and type members of ns
NSSASN1Sequence/ns NSSASN1Printable Item remain uninitialized
nsNSSASN1Sequence and nsNSSASN1PrintableItem do not initialize their mType and mTag member variables, so later calls to GetType() and GetTag() return garbage. For some reason these are not being filled in when the objects are created.
It seems that the nsNSSCertificate::CreateASN1Struct() code path does not initialize the tag and type fields.
Comment on attachment 195094 [details] [diff] [review] Patch I can't say if 0 is the right initial value for mType and mTag. But I verified that this patch is correct C++ code and it does no harm. 0 is an invalid value for mTag (valid values are 0x01 - 0x1f). For mType, 0 either means ASN1_END_CONTENTS or is invalid. So this patch replaces random garbage by fixed garbage, which is an improvement.
Attachment #195094 - Flags: review?(wtchang) → review+
Attachment #195094 - Flags: superreview?(rrelyea) → superreview+
The mType and mTag members are set by the buildASN1ObjectFromDER static function in security/manager/ssl/src/nsNSSASN1Object.cpp, which is only called by CreateFromDER, but no code calls CreateFromDER. If no code (other than the constructors after the proposed patch is applied) sets the mTag and mType members, then we shouldn't call the GetType and GetTag methods either. So one can also view the mTag and mType members as dead code and they should be removed along with the CreateFromDER and buildASN1ObjectFromDER functions, and the GetType, SetType, GetTag, SetTag methods.
Simon, can you describe the user impact and the risk in taking this patch?
As far as I know, there is no user impact, as I think no-one is using the accessors for those uninitialized fields. This is simply a "correctness" fix.
Fixed on trunk and branch.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.