alpine 3.8
format weakness #13


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.

 see  */

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "gmp.h"
#include "gmp-impl.h"

/* The data parameter "bufp" points to a "char *buf" which is the next
   character to be written, having started as the destination from the
   application.  This is then increased each time output is produced.  */

/* If vsprintf returns -1 then pass it upwards.  It doesn't matter that
   "*bufp" is ruined in this case, since gmp_doprint will bail out
   immediately anyway.  */
static int
gmp_sprintf_format (char **bufp, const char *fmt, va_list ap)
  char  *buf = *bufp;
  int   ret;
  vsprintf (buf, fmt, ap);
  ret = strlen (buf);
  *bufp = buf + ret;
  return ret;

static int
gmp_sprintf_memory (char **bufp, const char *str, size_t len)
  char  *buf = *bufp;
  *bufp = buf + len;
  memcpy (buf, str, len);
  return len;

static int
gmp_sprintf_reps (char **bufp, int c, int reps)
  char  *buf = *bufp;
  ASSERT (reps >= 0);
  *bufp = buf + reps;
  memset (buf, c, reps);
  return reps;

static int 

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.