Security/Tainting IPC Data: Difference between revisions

Jump to navigation Jump to search
add assertiontext to moz validate and get
(add moz validate or)
(add assertiontext to moz validate and get)
 
Line 27: Line 27:
While still experimental, we have envisioned a couple of macros that help unwrapping the tainted types.
While still experimental, we have envisioned a couple of macros that help unwrapping the tainted types.


==== <code>MOZ_VALIDATE_AND_GET(aValue, condition)</code> ====
==== <code>MOZ_VALIDATE_AND_GET(aValue, condition, assertionText)</code> ====
First and foremost, folks should use <code>MOZ_VALIDATE_AND_GET()</code>.
First and foremost, folks should use <code>MOZ_VALIDATE_AND_GET()</code>.
As you can see in the code sample above, the macro unwraps a <code>Taint&lt;T&gt;</code> and returns a <code>T</code>.
As you can see in the code sample above, the macro unwraps a <code>Taint&lt;T&gt;</code> and returns a <code>T</code>.
The second parameter of the macro should receive an boolean expression that ensures the value is within expected boundaries.
The second parameter of the macro should receive an boolean expression that ensures the value is within expected boundaries.
The value will only be unwrapped when the condition is true. If it is not, we will raise a <code>MOZ_RELEASE_ASSERT</code>.
The value will only be unwrapped when the condition is true. If it is not, we will raise a <code>MOZ_RELEASE_ASSERT</code>.
If this is not desirable, see below.
The assertion text is optional. If an assertion is not desirable, see below.


==== <code>MOZ_VALIDATE_OR(aValue, condition, defaultValue)</code> ====
==== <code>MOZ_VALIDATE_OR(aValue, condition, defaultValue)</code> ====
Confirmed users
239

edits

Navigation menu