`sprintf` is deprecated on MacOS if ASAN is enable.
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1.2k
- Forks
- 370
- PR merge metrics
- No merged PRs in 30d
Description
In dumper.c:
static yaml_char_t *
yaml_emitter_generate_anchor(SHIM(yaml_emitter_t *emitter), int anchor_id)
{
yaml_char_t *anchor = YAML_MALLOC(ANCHOR_TEMPLATE_LENGTH);
if (!anchor) return NULL;
sprintf((char *)anchor, ANCHOR_TEMPLATE, anchor_id);
return anchor;
}
You used sprintf. But when I enable ASAN and compile on Mac, I get this deprecation error:
/Users/richie/Documents/cxx_projects/iree.gd/thirdparty/iree/third_party/libyaml/src/dumper.c:254:5: error: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations]
sprintf((char *)anchor, ANCHOR_TEMPLATE, anchor_id);
^
I have suppress the error on my project, but it sure does feel like beat around the bush instead of directly solve the problem though. Hopefully it can be replace with the safer variant, snprintf, and make compiling on MacOS with ASAN much easier.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in dumper.c at yaml_emitter_generate_anchor and inspect ANCHOR_TEMPLATE_LENGTH alongside the existing formatting call. Build the project on macOS with ASAN enabled and confirm the deprecation warning is gone without changing the generated anchor text.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, macos
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100