Skip to content

sprintf with user controlled format string is unsafe #310

@Aeledfyr

Description

@Aeledfyr

PlotPieChart and RenderHeatmap call sprintf with a provided format string, which is unsafe.

sprintf(buffer, fmt, (double)values[i]);
sprintf(buff, fmt, values[i]);

This can lead to a simple buffer overflow, if the provided format string causes >32 characters of output, but it may also allow writing to arbitrary memory locations by using %n and reading local stack addresses using %p.

I don't know if there are ways to handle the second two issues, but using snprintf instead of sprintf should prevent potential buffer overflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions