Skip to content
  • Matt Turner's avatar
    pkcs11: Don't use strncpy when copying paths · 6c4ad4cf
    Matt Turner authored and Niels De Graef's avatar Niels De Graef committed
    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));
          |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~
    6c4ad4cf