2951a9a84bd85f384213a3e071ffc167907df2d7 |
|
13-Feb-2018 |
Lukas Slebodnik <lslebodn@redhat.com> |
CRYPTO: Suppress warning Wstringop-truncation
src/util/crypto/nss/nss_sha512crypt.c: In function ‘sha512_crypt_r’:
src/util/crypto/nss/nss_sha512crypt.c:270:10: warning: ‘stpncpy’ output
truncated copying 3 bytes from a string of length 3
[-Wstringop-truncation]
cp = stpncpy(buffer, sha512_salt_prefix, SALT_PREF_SIZE);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
man gcc says:
As another example, the following call to "strncpy" results in
copying to "d" just the characters preceding the terminating NUL,
without appending the NUL to the end. Assuming the result of
"strncpy" is necessarily a NUL-terminated string is a common
mistake, and so the call is diagnosed. To avoid the warning when
the result is not expected to be NUL-terminated, call "memcpy"
instead.
void copy (char *d, const char *s)
{
strncpy (d, s, strlen (s));
}
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com> |
83e1ea9e24aabe6ade180649ecfc9c253ad19395 |
|
18-May-2014 |
Lukas Slebodnik <lslebodn@redhat.com> |
CRYPTO: Use unprefixed version of function stpncpy
glibc contains two versions of finction stpncpy
sh-4.2$ nm --dynamic --defined-only /lib64/libc.so.6 | grep stpncpy
0000003ce1c89b00 i stpncpy
0000003ce1c89b00 i __stpncpy
0000003ce1d040a0 T __stpncpy_chk
We should use more portable version of stpncpy without prefix with underscores.
The function __stpncpy was used in initial veersion
e65c65fc710fa030bfb8319efc43fcdc9ce5a26f, which was based on
http://people.redhat.com/drepper/SHA-crypt.txt
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> |