Exercise 01: Tripping an Assert

For this exercise, make sure you run all commands from the directory:

  /path/to/cbat_tools/docs/exercises/01

The sample binary program

There is a program at binary/main. The source code lives at binary/main.c, though you should be able to complete this exercise without looking at the source code.

Imagine that this program is part of the software that runs on a badge reader. The task of this particular program is to check if a number is a valid employee ID.

You can try it, if you like. Try it with a valid employee ID:

    $ ./binary/main 0x39256
    $ echo $?

Try it with an invalid employee ID:

    $ ./binary/main 0x234
    $ echo $?

Your task

Use wp to complete the following tasks:

  1. Find out if it is possible to trip the assert in the function is_valid_ID.
  2. If it is possible to try the assert, use wp's output to determine an example of an argument that will trip the assert.
  3. Use bildb to step through the program line-by-line, and replicate the behavior of tripping the assert.

Solution

To see the solution, click here.