Remove a number of stringop-truncation warnings
Subsystems (2)
PATCH 1/2 Remove a number of stringop-truncation warnings
client.c:486:3: warning: ‘strncpy’ destination unchanged after
copying no bytes [-Wstringop-truncation]
file.c:99:2: warning: ‘strncpy’ specified bound 4096
equals destination size [-Wstringop-truncation]
v4root.c:95:2: warning: ‘strncpy’ specified bound 1025
equals destination size [-Wstringop-truncation]
sm-notify.c:572:3: warning: ‘strncpy’ specified bound 1025
equals destination size [-Wstringop-truncation]
nfs4mount.c:221:3: warning: ‘strncpy’ specified bound 1024
equals destination size [-Wstringop-truncation]
nfsmount.c:831:2: warning: ‘strncpy’ specified bound 256
equals destination size [-Wstringop-truncation]
--- support/export/client.c | 5 +++-- support/misc/file.c | 2 +- utils/mount/nfs4mount.c | 2 +- utils/mount/nfsmount.c | 2 +- utils/mountd/v4root.c | 2 +- utils/statd/sm-notify.c | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-)
support/export/client.c +3 -2
@@ -482,8 +482,9 @@ add_name(char *old, const char *add)else cp = cp +strlen (cp); } -if (old) { -strncpy (new, old, cp-old); + len = cp-old; +if (old && len >0 ) { +strncpy (new, old, len); new[cp-old] =0 ; }else { new[0 ] =0 ;
support/misc/file.c +1 -1
@@ -96,7 +96,7 @@ generic_setup_basedir(const char *progname, const char *parentdir, char *base, }/* Ensure we have a clean directory pathname */ -strncpy (buf, parentdir,sizeof (buf)); +strncpy (buf, parentdir,sizeof (buf)-1 ); path =dirname (buf);if (*path =='.' ) { (void)fprintf(stderr, "%s: Unusable directory %s",
utils/mount/nfs4mount.c +1 -1
@@ -218,7 +218,7 @@ int nfs4mount(const char *spec, const char *node, int flags, goto fail; }if (running_bg) -strncpy (new_opts, old_opts,sizeof (new_opts)); +strncpy (new_opts, old_opts,sizeof (new_opts)-1 );else snprintf (new_opts,sizeof (new_opts),"%s%saddr=%s" , old_opts, *old_opts ?"," :"" , s);
utils/mount/nfsmount.c +1 -1
@@ -828,7 +828,7 @@ noauth_flavors: data.fd = fsock;memcpy ((char *) &data.addr, (char *) nfs_saddr,sizeof (data.addr)); -strncpy (data.hostname, hostname,sizeof (data.hostname)); +strncpy (data.hostname, hostname,sizeof (data.hostname)-1 ); out_ok:/* Ensure we have enough padding for the following strcat()s */
utils/mountd/v4root.c +1 -1
@@ -92,7 +92,7 @@ v4root_create(char *path, nfs_export *export)dupexportent (&eep, &pseudo_root.m_export); eep.e_hostname = curexp->e_hostname; -strncpy (eep.e_path, path,sizeof (eep.e_path)); +strncpy (eep.e_path, path,sizeof (eep.e_path)-1 );if (strcmp (path,"/" ) !=0 ) eep.e_flags &= ~NFSEXP_FSID ;set_pseudofs_security (&eep, curexp->e_flags);
utils/statd/sm-notify.c +1 -1
@@ -569,7 +569,7 @@ usage: fprintf(stderr,if (name ==NULL )exit (1 ); -strncpy (nsm_hostname, name,sizeof (nsm_hostname)); +strncpy (nsm_hostname, name,sizeof (nsm_hostname)-1 );free (name); }
Signature · 1 line
2.17.1
PATCH 2/2 Remove a number of stringop-overflow warnings
umich_ldap.c:1128:3: warning: ‘strncat’ specified bound 128
equals destination size [-Wstringop-overflow=]
umich_ldap.c:1130:3: warning: ‘strncat’ specified bound 128
equals destination size [-Wstringop-overflow=]
idmapd.c:313:2: warning: ‘strncat’ specified bound 4096
equals destination size [-Wstringop-overflow=]
--- support/nfsidmap/umich_ldap.c | 4 ++-- utils/idmapd/idmapd.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
support/nfsidmap/umich_ldap.c +2 -2
@@ -1125,9 +1125,9 @@ umichldap_init(void)/* Verify required information is supplied */ if (server_in ==NULL ||strlen (server_in) ==0 ) -strncat (missing_msg,"LDAP_server " ,sizeof (missing_msg)); +strncat (missing_msg,"LDAP_server " ,sizeof (missing_msg)-1 );if (ldap_info.base ==NULL ||strlen (ldap_info.base) ==0 ) -strncat (missing_msg,"LDAP_base " ,sizeof (missing_msg)); +strncat (missing_msg,"LDAP_base " ,sizeof (missing_msg)-1 );if (strlen (missing_msg) !=0 ) {IDMAP_LOG (0 , ("umichldap_init: Missing required information: " "%s" , missing_msg));
utils/idmapd/idmapd.c +1 -1
@@ -310,7 +310,7 @@ main(int argc, char **argv)if (!serverstart && !clientstart)errx (1 ,"it is illegal to specify both -C and -S" ); -strncat (pipefsdir,"/nfs" ,sizeof (pipefsdir)); +strncat (pipefsdir,"/nfs" ,sizeof (pipefsdir)-1 );daemon_init (fg);
Signature · 1 line
2.17.1
Re: [PATCH 2/2] Remove a number of stringop-overflow warnings
Quoted 10 lines · Steve Dickson
umich_ldap.c:1128:3: warning: ‘strncat’ specified bound 128
equals destination size [-Wstringop-overflow=]umich_ldap.c:1130:3: warning: ‘strncat’ specified bound 128
equals destination size [-Wstringop-overflow=]idmapd.c:313:2: warning: ‘strncat’ specified bound 4096
equals destination size [-Wstringop-overflow=]Signed-off-by Steve Dickson <[email protected]>
Committed...
steved.
Quoted 35 lines
--- support/nfsidmap/umich_ldap.c | 4 ++-- utils/idmapd/idmapd.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)support/nfsidmap/umich_ldap.c +2
-2@@ -1125,9 +1125,9 @@ umichldap_init(void)/* Verify required information is supplied */ if (server_in ==NULL ||strlen (server_in) ==0 ) -strncat (missing_msg,"LDAP_server " ,sizeof (missing_msg)); +strncat (missing_msg,"LDAP_server " ,sizeof (missing_msg)-1 );if (ldap_info.base ==NULL ||strlen (ldap_info.base) ==0 ) -strncat (missing_msg,"LDAP_base " ,sizeof (missing_msg)); +strncat (missing_msg,"LDAP_base " ,sizeof (missing_msg)-1 );if (strlen (missing_msg) !=0 ) {IDMAP_LOG (0 , ("umichldap_init: Missing required information: " "%s" , missing_msg));utils/idmapd/idmapd.c +1
-1@@ -310,7 +310,7 @@ main(int argc, char **argv)if (!serverstart && !clientstart)errx (1 ,"it is illegal to specify both -C and -S" ); -strncat (pipefsdir,"/nfs" ,sizeof (pipefsdir)); +strncat (pipefsdir,"/nfs" ,sizeof (pipefsdir)-1 );daemon_init (fg);
Quoted 19 lines · Steve Dickson
client.c:486:3: warning: ‘strncpy’ destination unchanged after
copying no bytes [-Wstringop-truncation]file.c:99:2: warning: ‘strncpy’ specified bound 4096
equals destination size [-Wstringop-truncation]v4root.c:95:2: warning: ‘strncpy’ specified bound 1025
equals destination size [-Wstringop-truncation]sm-notify.c:572:3: warning: ‘strncpy’ specified bound 1025
equals destination size [-Wstringop-truncation]nfs4mount.c:221:3: warning: ‘strncpy’ specified bound 1024
equals destination size [-Wstringop-truncation]nfsmount.c:831:2: warning: ‘strncpy’ specified bound 256
equals destination size [-Wstringop-truncation]Signed-off-by Steve Dickson <[email protected]>
Quoted 8 lines
--- support/export/client.c | 5 +++-- support/misc/file.c | 2 +- utils/mount/nfs4mount.c | 2 +- utils/mount/nfsmount.c | 2 +- utils/mountd/v4root.c | 2 +- utils/statd/sm-notify.c | 2 +- 6 files changed, 8 insertions(+), 7 deletions(-)
Committed...
steved.
Quoted 83 lines
support/export/client.c +3
-2@@ -482,8 +482,9 @@ add_name(char *old, const char *add)else cp = cp +strlen (cp); } -if (old) { -strncpy (new, old, cp-old); + len = cp-old; +if (old && len >0 ) { +strncpy (new, old, len); new[cp-old] =0 ; }else { new[0 ] =0 ;support/misc/file.c +1
-1@@ -96,7 +96,7 @@ generic_setup_basedir(const char *progname, const char *parentdir, char *base, }/* Ensure we have a clean directory pathname */ -strncpy (buf, parentdir,sizeof (buf)); +strncpy (buf, parentdir,sizeof (buf)-1 ); path =dirname (buf);if (*path =='.' ) { (void)fprintf(stderr, "%s: Unusable directory %s",utils/mount/nfs4mount.c +1
-1@@ -218,7 +218,7 @@ int nfs4mount(const char *spec, const char *node, int flags, goto fail; }if (running_bg) -strncpy (new_opts, old_opts,sizeof (new_opts)); +strncpy (new_opts, old_opts,sizeof (new_opts)-1 );else snprintf (new_opts,sizeof (new_opts),"%s%saddr=%s" , old_opts, *old_opts ?"," :"" , s);utils/mount/nfsmount.c +1
-1@@ -828,7 +828,7 @@ noauth_flavors: data.fd = fsock;memcpy ((char *) &data.addr, (char *) nfs_saddr,sizeof (data.addr)); -strncpy (data.hostname, hostname,sizeof (data.hostname)); +strncpy (data.hostname, hostname,sizeof (data.hostname)-1 ); out_ok:/* Ensure we have enough padding for the following strcat()s */ utils/mountd/v4root.c +1
-1@@ -92,7 +92,7 @@ v4root_create(char *path, nfs_export *export)dupexportent (&eep, &pseudo_root.m_export); eep.e_hostname = curexp->e_hostname; -strncpy (eep.e_path, path,sizeof (eep.e_path)); +strncpy (eep.e_path, path,sizeof (eep.e_path)-1 );if (strcmp (path,"/" ) !=0 ) eep.e_flags &= ~NFSEXP_FSID ;set_pseudofs_security (&eep, curexp->e_flags);utils/statd/sm-notify.c +1
-1@@ -569,7 +569,7 @@ usage: fprintf(stderr,if (name ==NULL )exit (1 ); -strncpy (nsm_hostname, name,sizeof (nsm_hostname)); +strncpy (nsm_hostname, name,sizeof (nsm_hostname)-1 );free (name); }