More checks in ELF parser.

Hello, I'm working on the radare2 ELF parser.

I found many bugs on it due to lack of checks on ELF structure fields, which result to segfault (or more 3vil things...).

If you are interested, I'm rewriting the parser (partialy) in the goal to made it more secure and more robust.

Here is the first patch I submit, but there are still bugs, and I need to rewrite other functions.

If you have question on my code, I'm open to discussion ;)

-TOSH-
Yep. Static inline is better here :p



> On 22 Jun 2014, at 13:20, jvoisin <notifications@github.com> wrote:
> 
> In libr/util/safe_int.c:
> 
> > +   ======================================================================= */
> > +
> > +#include <r_types.h>
> > +#include <stdlib.h>
> > +
> > +/* All functions have the form :
> > +   r_safe_[OP][S][SIZE]
> > +   - OP is one of mul, add, sub
> > +   - S is 'u' for unsigned and 's' for signed
> > +   - SIZE is one of 8, 16, 32, 64.
> > +
> > +   The operand 'r' is the result, and can be NULL.
> > +   'a' and 'b' are the two operands for the given operation.
> > +*/
> > +
> > +R_API int r_safe_addu64(ut64 *r, ut64 a, ut64 b) {
> #define ADDut64(r,a,b) ((UT64_MAX-a)<b)?0:r?*r=a+b:1:1
> This is barely readable :|
> 
> —
> Reply to this email directly or view it on GitHub.