Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openssl: gcc8 warning -Wstringop-truncation #2980

Closed
vszakats opened this issue Sep 11, 2018 · 1 comment
Closed

openssl: gcc8 warning -Wstringop-truncation #2980

vszakats opened this issue Sep 11, 2018 · 1 comment

Comments

@vszakats
Copy link
Member

@vszakats vszakats commented Sep 11, 2018

i686-w64-mingw32-gcc -I. -I../include -I"../../nghttp2/pkg/usr/local/include" -I"../../libssh2/include" -I"../../libssh2/win32" -I"../../openssl/include" -I"../../zlib/pkg/usr/local" -I"../../brotli/pkg/usr/local/include" -DCURL_STATICLIB -fno-ident -DCURL_DISABLE_SSL_AUTO_LOAD_CONFIG -fno-asynchronous-unwind-tables -DNGHTTP2_STATICLIB -g -O2 -Wall -W -fno-strict-aliasing -m32 -DBUILDING_LIBCURL -DCURL_WITH_MULTI_SSL -DUSE_NGHTTP2 -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP -DUSE_SCHANNEL -DHAVE_LIBZ -DHAVE_ZLIB_H -DHAVE_BROTLI -DUSE_WIN32_IDN -DWANT_IDN_PROTOTYPES -DUSE_WINDOWS_SSPI -DENABLE_IPV6 -D_WIN32_WINNT=0x0501 -DHAVE_LDAP_SSL -c vtls/openssl.c -o vtls/openssl.o
In function 'ossl_keylog_callback.part.2',
    inlined from 'ossl_keylog_callback':
vtls/openssl.c:256:5: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
     strncpy(buf, line, linelen);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/openssl.c: In function 'ossl_keylog_callback':
vtls/openssl.c:247:22: note: length computed here
     size_t linelen = strlen(line);
                      ^~~~~~~~~~~~
In function 'ossl_keylog_callback.part.2',
    inlined from 'ossl_keylog_callback':
vtls/openssl.c:256:5: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
     strncpy(buf, line, linelen);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
vtls/openssl.c: In function 'ossl_keylog_callback':
vtls/openssl.c:247:22: note: length computed here
     size_t linelen = strlen(line);
                      ^~~~~~~~~~~~

Can't spot what may be wrong with the code. Swapping strncpy() for memcpy() makes the warning disappear.

@jay jay closed this in 357161a Sep 12, 2018
@jay
Copy link
Member

@jay jay commented Sep 12, 2018

Nothing is wrong with it but memcpy is fine so let's do that.

vszakats added a commit to vszakats/curl that referenced this issue Sep 12, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Dec 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.