Open Bug 406527 Opened 17 years ago Updated 3 years ago

Exception Service's registerExceptionProvider is too loose with its module arguments

Categories

(Core :: XPCOM, defect, P5)

defect

Tracking

()

People

(Reporter: WeirdAl, Unassigned)

References

()

Details

Our nsresult codes, per nsrootidl.idl, have 32 bits. Of these, bits 16-30 are reserved for module codes, per nsError.h. Yet nsIExceptionService.registerExceptionProvider and .unregisterExceptionProvider take as a second argument a full 32 bits for the module code. The inline documentation and largish argument would imply a very big number for the module code... yet the only mainstream consumer of it, nsDOMScriptObjectFactory.cpp, sets arguments in the PRUint8 range. Also, there is no validation of the module code argument within the exception service. If the number's too big, who knows what nsresult codes will map to it? I recommend changing the arguments to PRUint16, enforcing a constraint that the module code can be no larger than 32698 (Math.pow(2,15) - 0x45), and documenting what valid argument values there can be. I'm willing to submit a patch; who wants to review?
32698 == Math.pow(2,15) - 0x45 - 1. The 0x45 comes from nsError.h, as NS_ERROR_MODULE_BASE_OFFSET.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.