Skip to content
Snippets Groups Projects
Commit 0565882c authored by Simon McVittie's avatar Simon McVittie
Browse files

safe_strncpy: Work around -Werror=stringop-truncation


Ideally we should bubble up errors to the caller rather than silently
truncating, but if we have to truncate, let's at least be sufficiently
explicit about it that gcc 8 doesn't sulk.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent b636d25f
Branches
Tags
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
......@@ -169,7 +169,7 @@ find_symbol (int idx, const ElfW(Sym) *stab, size_t symsz, const char *str, size
// way about truncation though, should probably fix that:
char *safe_strncpy (char *dest, const char *src, size_t n)
{
char *rv = strncpy( dest, src, n );
char *rv = strncpy( dest, src, n - 1 );
dest[ n - 1 ] = '\0';
return rv;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment