fedora 23
format weakness #38

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.

File Name:

apitrace-7.1/common/os.hpp

Context:

The highlighted line of code below is the trigger point of this particular Fedora 23 format weakness.

 
#pragma once

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

#ifdef _WIN32
#ifndef snprintf
#define snprintf _snprintf
#endif
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#endif
#ifndef strcasecmp
#define strcasecmp stricmp
#endif
#endif /* !_WIN32 */

namespace os {

void log(const char *format, ...)
#ifdef __GNUC__
    __attribute__ ((format (printf, 1, 2)))
#endif
;

#if defined _WIN32 || defined __CYGWIN__
  /* We always use .def files on windows for now */
  #if 0
  #define PUBLIC __declspec(dllexport)
  #else
  #define PUBLIC
  #endif
  #define PRIVATE
#else
  #define PUBLIC __attribute__ ((visibility("default")))
  #define PRIVATE __attribute__ ((visibility("hidden")))
#endif

/**
 * Exit immediately.
 *
 * This should be called only from the wrappers, when there is no safe way of
 * failing gracefully.
 */
// coverity[+kill]
#ifdef _MSC_VER
__declspec(noreturn) 

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.