alpine 3.8
format weakness #8


Weakness Breakdown


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):

Potential format string problem.

File Name:



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

 	      int  n = 0;
	      do {
		n = n * 10 + (fchar-'0');
		fchar = *fmt++;
	      } while (isascii (fchar) && isdigit (fchar));
	      fmt--; /* unget the non-digit */
	      *value = n;

	    /* incomplete or invalid % sequence */
	    ASSERT (0);
	    goto next;

      total_width += width;
      total_width += prec;

  if (total_width <= buf_size)
      vsprintf (buf, orig_fmt, orig_ap);
      len = strlen (buf);
      char  *s;

      s = __GMP_ALLOCATE_FUNC_TYPE (total_width, char);
      vsprintf (s, orig_fmt, orig_ap);
      len = strlen (s);
      if (buf_size != 0)
	  size_t  copylen = MIN (len, buf_size-1);
	  memcpy (buf, s, copylen);
	  buf[copylen] = '\0';
      (*__gmp_free_func) (s, total_width);

  /* If total_width was somehow wrong then chances are we've already
     clobbered memory, but maybe this check will still work.  */
  ASSERT_ALWAYS (len < total_width);

  return len;

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.