Kitty: build: stringop-overflow warning

Created on 18 Jun 2018  Â·  7Comments  Â·  Source: kovidgoyal/kitty

I am seeing the following warning when building kitty:

In function ‘get_exts’,
    inlined from ‘find_extensionsGL’ at …/Vcs/kitty/kitty/gl-wrapper.c:3747:7,
    inlined from ‘gladLoadGLLoader.part.2’ at …/Vcs/kitty/kitty/gl-wrapper.c:3821:7:
…/Vcs/kitty/kitty/gl-wrapper.c:189:17: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=]
                 strncpy(local_str, gl_str_tmp, len+1);
                 ^
…/Vcs/kitty/kitty/gl-wrapper.c: In function ‘gladLoadGLLoader.part.2’:
…/Vcs/kitty/kitty/gl-wrapper.c:183:26: note: length computed here
             size_t len = strlen(gl_str_tmp);
                          ^

The code appears to be fine, but would be nice to silence this: https://github.com/kovidgoyal/kitty/blob/4c0f68150a2f32ab8b8e81f7a3c4f746e714a4a4/kitty/gl-wrapper.c#L182-L189

Most helpful comment

Hey, I just found that issue by pure accident - I was just looking for a new terminal!

I'll fix that.

All 7 comments

Sadly, this is generated code from the glad project, so it would need to be silenced there. gl-wrapper is generated from glad.py. You can report it upstream https://github.com/Dav1dde/glad https://github.com/Dav1dde/glad/blob/1b1b3bed219d45a22d8b4bd0a25245de08e2423d/glad/lang/c/loader/gl.py#L62

Hey, I just found that issue by pure accident - I was just looking for a new terminal!

I'll fix that.

@Dav1dde
Cool!
Now you can have a terminal using your project.. :)

@Dav1dde you might also be interested in #701

It's also a harmless thing, but...

That's a won't fix for this version of glad, I have an almost done 2.0 which addresses this.

It's a won't fix because I will still be using __gl_h_ so you'd still get compiler/code analysis warnings, so for me that's no reason to potentially break someone's code. 2.0 on the other hand breaks code anyways so I changed it there.

If you have any feature requests or issues with glad, let me know - I love seeing people use it!

No worries, as I said it is harmless. My biggest feature request is to allow switching to the debug variants at runtime rather than compile time. I do that already in kitty (to support the --debug-gl command line option) by post-processing glad output, but it would be nice to have that as a builtin feature in glad.

That's https://github.com/Dav1dde/glad/issues/68
Let's see if I find time for this on the weekend, but I'll probably won't backport that to the current master version.

Anyways to not completely hijack this issue: 0.1.25 is released which contains a fix for this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lazarcf picture lazarcf  Â·  4Comments

atomsymbol picture atomsymbol  Â·  3Comments

wavexx picture wavexx  Â·  3Comments

metalelf0 picture metalelf0  Â·  4Comments

jasminabasurita picture jasminabasurita  Â·  3Comments