Skip to content

Commit

Permalink
Fedora 28: Fix misc bounds check compiler warnings
Browse files Browse the repository at this point in the history
Fix a bunch of truncation compiler warnings that show up
on Fedora 28 (GCC 8.0.1).

Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Issue openzfs#7368
Closes openzfs#7826
Closes openzfs#7830
  • Loading branch information
dioni21 authored and tonyhutter committed Jul 6, 2018
1 parent 4356dd2 commit 3ea1f7f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/libshare/smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ smb_enable_share_one(const char *sharename, const char *sharepath)
int rc;

/* Support ZFS share name regexp '[[:alnum:]_-.: ]' */
strncpy(name, sharename, sizeof (name));
strlcpy(name, sharename, sizeof (name));
name [sizeof (name)-1] = '\0';

pos = name;
Expand Down
2 changes: 1 addition & 1 deletion module/icp/core/kcf_mech_tabs.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ kcf_create_mech_entry(kcf_ops_class_t class, char *mechname)
mutex_enter(&(me_tab[i].me_mutex));
if (me_tab[i].me_name[0] == 0) {
/* Found an empty spot */
(void) strncpy(me_tab[i].me_name, mechname,
(void) strlcpy(me_tab[i].me_name, mechname,
CRYPTO_MAX_MECH_NAME);
me_tab[i].me_name[CRYPTO_MAX_MECH_NAME-1] = '\0';
me_tab[i].me_mechid = KCF_MECHID(class, i);
Expand Down
2 changes: 1 addition & 1 deletion tests/zfs-tests/tests/functional/ctime/ctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ do_link(const char *pfile)
return (-1);
}

strncpy(pfile_copy, pfile, sizeof (pfile_copy));
strncpy(pfile_copy, pfile, sizeof (pfile_copy)-1);
pfile_copy[sizeof (pfile_copy) - 1] = '\0';
/*
* Figure out source file directory name, and create
Expand Down

0 comments on commit 3ea1f7f

Please sign in to comment.