alpine 3.7
format weakness #19


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

If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always 0-terminate.

File Name:



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

 /* This if for random.c. */
#define gettimeofday	vms_gettimeofday
#ifndef __TIMEVAL
#define __TIMEVAL 1
struct timeval	{ long tv_sec, tv_usec; };
extern int   gettimeofday(struct timeval *,void *);

#else	/* awk.h, not POSIX */

/* some macros to redirect to code in vms/vms_misc.c */
#ifndef bcopy
#define bcopy		vms_bcopy
#define open		vms_open
#define popen		vms_popen
#define pclose		vms_pclose
#define snprintf gawk_snprintf	/* avoid %CC-I-INTRINSICDECL diagnostic */
#define vsnprintf gawk_vsnprintf
/* supply missing or suppressed (due to defines in config.h) declarations */
extern int snprintf(char *,size_t,const char *,...);
extern int vsnprintf(char *restrict,size_t,const char *,va_list);
extern int setenv(const char *,const char *,int);
extern int unsetenv(const char *);
#define strerror	vms_strerror
#define strdup		vms_strdup
#define unlink		vms_unlink
#if defined(VAXC) || (defined(__GNUC__) && !defined(__alpha))
#define fstat(fd,sb)	VMS_fstat(fd,sb)
extern void  exit(int);
extern int   open(const char *,int,...);
extern char *strerror(int);
extern char *strdup(const char *str);
extern int   vms_devopen(const char *,int);
# ifndef NO_TTY_FWRITE
#define fwrite		tty_fwrite
#define fclose		tty_fclose
extern size_t fwrite(const void *,size_t,size_t,FILE *);
extern int    fclose(FILE *);
# endif
extern FILE *popen(const char *,const char *);
extern int   pclose(FILE *);
extern void vms_arg_fixup(int *,char ***);
/* some things not in STDC_HEADERS */
extern size_t gnu_strftime(char *,size_t,const char *,const struct tm *);
extern int unlink(const char *); 

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.