Skip to content

pkcs11: Don't use strncpy when copying paths

Matt Turner requested to merge mattst88/gnome-keyring:no-strncpy into master

Using strncpy produces the following warning, which indicates that the destination string could be left unterminated.

  CC       daemon/control/gkd-control-server.lo
  CCLD     libgkd-control.la
  CC       pkcs11/rpc-layer/libgkm_rpc_layer_la-gkm-rpc-dispatch.lo
In file included from /usr/include/string.h:519,
                 from /usr/include/glib-2.0/glib/galloca.h:33,
                 from /usr/include/glib-2.0/glib.h:30,
                 from ./egg/egg-error.h:24,
                 from pkcs11/rpc-layer/gkm-rpc-dispatch.c:31:
In function ‘strncpy’,
    inlined from ‘gkm_rpc_layer_startup’ at pkcs11/rpc-layer/gkm-rpc-dispatch.c:2382:2:
/usr/include/bits/string_fortified.h:95:10: warning: ‘__builtin_strncpy’ specified bound 108 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |                                   __glibc_objsize (__dest));
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~

Merge request reports