centos 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.

File Name:



The highlighted line of code below is the trigger point of this particular Centos 7 format weakness.

         s[len-1] = 0;

        return s;

#define HIGHLIGHT "\x1B[1m"
#define ENDHIGHLIGHT "\x1B[0m"

static void disk_dump_attributes(SkDisk *d, const SkSmartAttributeParsedData *a, void* userdata) {
        char name[32];
        char pretty[32];
        char tt[32], tw[32], tc[32];
        SkBool highlight;

        snprintf(tt, sizeof(tt), "%3u", a->threshold);
        tt[sizeof(tt)-1] = 0;
        snprintf(tw, sizeof(tw), "%3u", a->worst_value);
        tw[sizeof(tw)-1] = 0;
        snprintf(tc, sizeof(tc), "%3u", a->current_value);
        tc[sizeof(tc)-1] = 0;

        highlight = a->warn && isatty(1);

        if (highlight)
                fprintf(stderr, HIGHLIGHT);

        printf("%3u %-27s %-3s   %-3s   %-3s   %-11s 0x%02x%02x%02x%02x%02x%02x %-7s %-7s %-4s %-4s\n",
               print_name(name, sizeof(name), a->id, a->name),
               a->current_value_valid ? tc : "n/a",
               a->worst_value_valid ? tw : "n/a",
               a->threshold_valid ? tt : "n/a",
               print_value(pretty, sizeof(pretty), a->pretty_value, a->pretty_unit),
               a->raw[0], a->raw[1], a->raw[2], a->raw[3], a->raw[4], a->raw[5],
               a->prefailure ? "prefail" : "old-age",
               a->online ? "online" : "offline",
               a->good_now_valid ? yes_no(a->good_now) : "n/a",
               a->good_in_the_past_valid ? yes_no(a->good_in_the_past) : "n/a");

        if (highlight)
                fprintf(stderr, ENDHIGHLIGHT);

int sk_disk_dump(SkDisk *d) {
        int ret;
        SkBool awake = FALSE;
        uint64_t size;


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.