Skip to content

openssl: gcc8 warning -Wstringop-truncation #2980

Closed

Description

@vszakats
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.

Activity

  1. jay commented on Sep 12, 2018

    @jay
    Member

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

  2. added a commit that references this issue on Sep 12, 2018
  3. locked as resolved and limited conversation to collaborators on Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions