KhronosGroup / KhronosGroup/Vulkan-Docs
Prevent concatenation for string constants in headers?
@oddhack is already working on this.
Since Aug 28, 2024.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 549
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 2
Description
So I've encountered the most stupid thing ever: https://infosec.exchange/@kanashimia/113033538870920565
Because string constants such as VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME are defined using preprocessor you can concatenate them accidentally.
Maybe it would be appropriate to wrap them in a parenthesis.
Quoting from the post:
GCC doesn't warn you about string concatenations at all.
Clang has -Wstring-concatenation, but that doesn't work through defines.
So IDE based on clangd won't warn about it too.If these strings were defined in parenthesis as
# define FOO ("foo")
then such problems couldn't occur, you can't concatenate("foo") ("bar").
Although not sure if that causes any other problems, maybe some people do rely on the ability to concatenate those strings?
Who knows.
Spec is written in a weird way where it contains quotes value=""VK_KHR_video_encode_queue"", I guess just for an easier C generation, but ideally this should be fixed just for C headers, it isn't appropriate to change the spec because of this and break other binding generators.
This is technically a breaking change at the headers API level, but do people really rely on this?
What other possible problems can wrapping string in () cause?
I just throw this out for thinking and laughs, overall the issue is minor and may be ignored, you decide.
Contributor guide
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.
Assessment
This issue has not been assessed yet.