• Daniel P. Berrangé's avatar
    Ensure nul termination of hostname · d7684186
    Daniel P. Berrangé authored
    Newest GCC warns that the string copying is potentially truncated and
    thus not nul terminated.
    
    In file included from /usr/include/string.h:494,
                     from ../../src/Virt_HostSystem.c:23:
    In function ‘strncpy’,
        inlined from ‘resolve_host’ at ../../src/Virt_HostSystem.c:55:28,
        inlined from ‘get_fqdn’ at ../../src/Virt_HostSystem.c:92:23,
        inlined from ‘set_host_system_properties’ at ../../src/Virt_HostSystem.c:109:13:
    /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 256 equals destination size [-Werror=stringop-truncation]
      106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In function ‘strncpy’,
        inlined from ‘resolve_host’ at ../../src/Virt_HostSystem.c:67:17,
        inlined from ‘get_fqdn’ at ../../src/Virt_HostSystem.c:92:23,
        inlined from ‘set_host_system_properties’ at ../../src/Virt_HostSystem.c:109:13:
    /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ specified bound 256 equals destination size [-Werror=stringop-truncation]
      106 |   return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest));
          |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    cc1: all warnings being treated as errors
    Signed-off-by: 's avatarDaniel P. Berrangé <berrange@redhat.com>
    d7684186
Virt_HostSystem.c 8.24 KB