alpine 3.8
format weakness #27

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

If format strings can be influenced by an attacker, they can be exploited.

File Name:

gmp/src/gmp-6.1.2/tests/trace.c

Context:

The highlighted line of code below is the trigger point of this particular Alpine 3.8 format weakness.

 
/* Print "name=value\n" to stdout for an mpf_t value. */
void
mpf_trace (const char *name, mpf_srcptr f)
{
  mp_trace_start (name);
  if (f == NULL)
    {
      printf ("NULL\n");
      return;
    }

  mpf_out_str (stdout, ABS (mp_trace_base), 0, f);
  printf ("\n");
}


/* Print "namenum=value\n" to stdout for an mpz_t value.
   "name" should have a "%d" to get the number. */
void
mpz_tracen (const char *name, int num, mpz_srcptr z)
{
  if (name != NULL && name[0] != '\0')
    {
      printf (name, num);
      putchar ('=');
    }
  mpz_trace (NULL, z);
}


/* Print "name=value\n" to stdout for an mpn style ptr,size. */
void
mpn_trace (const char *name, mp_srcptr ptr, mp_size_t size)
{
  mpz_t  z;
  if (ptr == NULL)
    {
      mpz_trace (name, NULL);
      return;
    }
  MPN_NORMALIZE (ptr, size);
  PTR(z) = (mp_ptr) ptr;
  SIZ(z) = size;
  ALLOC(z) = size;
  mpz_trace (name, z);
}

/* Print "name=value\n" to stdout for a limb, nail doesn't have to be zero. */
void 

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.