platform_external_selinux/libselinux
Nicolas Iooss f1bc162cc2 libselinux: silence -Wstringop-overflow warning from gcc 10.3.1
When building libselinux on Fedora 33 with gcc 10.3.1, the compiler
reports:

    label_file.c: In function ‘lookup_all.isra’:
    label_file.c:940:4: error: ‘strncpy’ specified bound depends on the
    length of the source argument [-Werror=stringop-overflow=]
      940 |    strncpy(clean_key, key, len - 1);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    label_file.c:927:8: note: length computed here
      927 |  len = strlen(key);
          |        ^~~~~~~~~~~
    cc1: all warnings being treated as errors

As clean_key is the result of malloc(len), there is no issue here. But
using strncpy can be considered as strange, because the size of the
string is already known and the NUL terminator is always added later, in
function ‘lookup_all.isra.

Replace strncpy with memcpy to silence this gcc false-positive warning.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Acked-by: Petr Lautrbach <plautrba@redhat.com>
2021-05-12 09:35:50 +02:00
..
include libselinux: accept const fromcon in get_context API 2021-01-20 16:53:34 +01:00
man selinux(8,5): Describe fcontext regular expressions 2021-02-19 15:18:05 +01:00
src libselinux: silence -Wstringop-overflow warning from gcc 10.3.1 2021-05-12 09:35:50 +02:00
utils libselinux/getconlist: report failures 2021-02-19 15:15:11 +01:00
LICENSE initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
Makefile libselinux: do not duplicate make target when going into subdirectory 2021-04-30 21:09:22 +02:00
VERSION Update VERSIONs to 3.2 for release. 2021-03-04 16:42:59 +01:00