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

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.9 format weakness.

     longjmp(test_exit_jmp_buf[jmp_buf_index], 1);

static void  DosRestoreJumpBuffer()

int (*PlatformSpecificSetJmp)(void (*function) (void*), void*) = DosSetJmp;
void (*PlatformSpecificLongJmp)(void) = DosLongJmp;
void (*PlatformSpecificRestoreJumpBuffer)(void) = DosRestoreJumpBuffer;

static long DosTimeInMillis()
    return clock() * 1000 / CLOCKS_PER_SEC;

static const char* DosTimeString()
    time_t tm = time(NULL);
    return ctime(&tm);

static int DosVSNprintf(char* str, size_t size, const char* format, va_list args) {
    return vsnprintf(str, size, format, args);

long (*GetPlatformSpecificTimeInMillis)() = DosTimeInMillis;
const char* (*GetPlatformSpecificTimeString)() = DosTimeString;
int (*PlatformSpecificVSNprintf)(char *, size_t, const char*, va_list) = DosVSNprintf;

PlatformSpecificFile DosFOpen(const char* filename, const char* flag)
    return fopen(filename, flag);

static void DosFPuts(const char* str, PlatformSpecificFile file)
   fputs(str, (FILE*)file);

static void DosFClose(PlatformSpecificFile file)

PlatformSpecificFile (*PlatformSpecificFOpen)(const char* filename, const char* flag) = DosFOpen;
void (*PlatformSpecificFPuts)(const char* str, PlatformSpecificFile file) = DosFPuts;
void (*PlatformSpecificFClose)(PlatformSpecificFile file) = DosFClose;

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.