centos 6
integer weakness #2


Weakness Breakdown


An integer overflow occurs when the answer to an arithmetic operation exceeds the maximum size of the integer type used to store it. The resulting value will appear to have wrapped around the maximum value and started again at the minimum value. This would look like a clock that represents 13:00 by pointing at 1:00. An attacker can use an integer overflow during a buffer length calculation, which results in the allocated buffer being too small to hold the data copied into it, thus causing a buffer overflow.

Warning code(s):

Unless checked, the resulting number can exceed the expected range.

File Name:



The highlighted line of code below is the trigger point of this particular Centos 6 integer weakness.

     bool optimized;
    char **filenames;
    int num_filenames;
    int max_frames;
    int min_cluster_size;
    float cut_level;

static error_t
parse_opt(int key, char *arg, struct argp_state *state)
    /* Get the input argument from argp_parse, which we
       know is a pointer to our arguments structure. */
    struct arguments *arguments = (struct arguments*)state->input;

    switch (key)
    case 'r': arguments->output = RATE; break;
    case 'c': arguments->output = CRASH_FUNCTION; break;
    case 'h': arguments->output = DUPLICATION_HASH; break;
    case 'd': arguments->debug = true; break;
    case 'v': arguments->verbose = true; break;
    case 'i': arguments->stdin = true; break;
    case 'o': arguments->optimized = true; break;
    case 'm': arguments->max_frames = atoi(arg); break;
    case 's': arguments->output = DISTANCES; break;
    case 'g': arguments->output = DENDROGRAM; break;
    case 'l': arguments->output = CLUSTERS; arguments->cut_level = atof(arg); break;
    case 'z': arguments->min_cluster_size = atoi(arg); break;
    case ARGP_KEY_ARGS:
        arguments->filenames = state->argv + state->next;
        arguments->num_filenames = state->argc - state->next;
    case ARGP_KEY_END:
        switch (arguments->output)
        case DISTANCES:
        case CLUSTERS:
        case DENDROGRAM:
            if (arguments->num_filenames < 2 || arguments->stdin) {
                /* At least two filenames required */
                exit(EX_USAGE); /* Invalid argument */
            if ((arguments->num_filenames != 1 && !arguments->stdin) ||
                    (arguments->num_filenames != 0 && arguments->stdin)) {
                /* Argument required */

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.