openframeworks / openframeworks/openFrameworks

ofUtils warnings - snprintf, requires a string literal

Open
#7,392 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10.4k
Forks
2.6k
Avg merge
1d 21h
Merged PRs (30d)
9

Description

we can add fmt lib to the core to deal with format

/Volumes/tool/ofw/libs/openFrameworks/utils/ofUtils.h:600:45: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        size_t n = std::snprintf(buf, sizeof(buf), format, std::forward<Args>(args)...);

/Volumes/tool/ofw/libs/openFrameworks/utils/ofUtils.h:600:45: note: treat the string as an argument to avoid this
        size_t n = std::snprintf(buf, sizeof(buf), format, std::forward<Args>(args)...);

/Volumes/tool/ofw/libs/openFrameworks/utils/ofUtils.h:612:55: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
        std::snprintf(const_cast<char*>(s.data()), s.size(), format, std::forward<Args>(args)...);
                                                             ^~~~~~
/Volumes/tool/ofw/libs/openFrameworks/utils/ofUtils.h:612:55: note: treat the string as an argument to avoid this
        std::snprintf(const_cast<char*>(s.data()), s.size(), format, std::forward<Args>(args)...);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing libs/openFrameworks/utils/ofUtils.h around lines 600 and 612, where the reported std::snprintf warnings occur, and inspect the surrounding formatting entry points. Build the affected target to reproduce the warnings and evaluate the proposed fmt approach; done means the warnings are resolved without breaking formatting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.