fedora 23
buffer weakness #6

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Easily used incorrectly.

File Name:

hmmer-3.1b2/src/hmmc2.c

Context:

The highlighted line of code below is the trigger point of this particular Fedora 23 buffer weakness.

           fprintf(stderr, "[%s:%d] read error %d - %s\n", __FILE__, __LINE__, errno, strerror(errno));
          exit(1);
        }
        fprintf(stderr, "ERROR (%d): %s\n", sstatus.status, ebuf);
        free(ebuf);
      }

      continue;
    }

    /* process search specific options */
    if (*ptr == '@') {
      char t;
      char *s = ++ptr;

      /* skip to the end of the line */
      while (*ptr && (*ptr != '\n' && *ptr != '\r')) ++ptr;
      t = *ptr;
      *ptr = 0;

      /* create a commandline string with dummy program name for
       * the esl_opt_ProcessSpoof() function to parse.
       */
      strncpy(opts, "X ", MAX_READ_LEN);
      strncat(opts, s,    MAX_READ_LEN);
      strncat(opts, "\n", MAX_READ_LEN);
      opts[MAX_READ_LEN-1] = 0;

      if (esl_getopts_Reuse(go) != eslOK) p7_Die("Internal failure reusing options object");
      if (esl_opt_ProcessSpoof(go, opts) != eslOK) { 
        printf("Failed to parse options string: %s\n", go->errbuf);
        continue;
      }
      if (esl_opt_VerifyConfig(go) != eslOK) { 
        printf("Failed to parse options string: %s\n", go->errbuf);
        continue;
      }

      /* the options string can handle an optional database */
      if (esl_opt_ArgNumber(go) != 0) { 
        printf("Incorrect number of command line arguments.");
        continue;
      }

      /* skip remaining white spaces */
      *ptr = t;
      while (*ptr && isspace(*ptr)) ++ptr;
    }

 

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.