21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter CHAPTER 13 13<br />

Other Topics<br />

Each of the earlier chapters focused on one particular topic. Each of those topics is<br />

vast and clearly warrants a dedicated chapter. In addition, several smaller topics<br />

(while no less important) don’t quite warrant a chapter all their own. This chapter is<br />

a collection of those smaller topics.<br />

13.1 Performing Error Handling<br />

<strong>Problem</strong><br />

Many security vulnerabilities are possible as a consequence of a programmer’s omitting<br />

proper error handling. Developers find it extremely taxing to have to check error<br />

conditions continually. The unfortunate result is that these conditions often go forgotten.<br />

Solution<br />

If you have the luxury of designing an API, design it in such a way that it minimizes<br />

the amount of error handling that is required, if at all possible. In addition, try to<br />

design APIs so that failures are not potentially critical if they go unhandled.<br />

Otherwise, appropriate exception handling can help you ensure that no errors that<br />

go unhandled will propagate dangerous error conditions. Use wrappers to convert<br />

functions that may fail with a traditional error code, so that they instead use exception<br />

handling.<br />

Discussion<br />

There are plenty of situations in which assuming that a function returns successfully<br />

leads to a security vulnerability. One simple example is the case of using a secure<br />

random number generator to fill a buffer with random bytes. If the return value indi-<br />

700<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!