alpine 3.7
format weakness #16

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, and note that sprintf variations do not always 0-terminate.

File Name:

gawk/src/gawk-4.2.0/vms/redirect.h

Context:

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

    to prevent diagnostics about various implicitly declared functions.  */
#include <stdlib.h>
#include <string.h>
#endif
#ifndef VMS_POSIX
/* This if for random.c. */
#define gettimeofday	vms_gettimeofday
#ifndef __TIMEVAL
#define __TIMEVAL 1
struct timeval	{ long tv_sec, tv_usec; };
#endif
extern int   gettimeofday(struct timeval *,void *);
#endif

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

/* some macros to redirect to code in vms/vms_misc.c */
#ifndef bcopy
#define bcopy		vms_bcopy
#endif
#define open		vms_open
#define popen		vms_popen
#define pclose		vms_pclose
#ifndef HAVE_SNPRINTF
#define snprintf gawk_snprintf	/* avoid %CC-I-INTRINSICDECL diagnostic */
#define vsnprintf gawk_vsnprintf
#endif
/* 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)
#endif
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 *); 

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.