summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authorgreen <green@FreeBSD.org>1999-10-30 17:56:47 +0000
committergreen <green@FreeBSD.org>1999-10-30 17:56:47 +0000
commit769c5f26dfd6a4c21bbcab3904a783bc04083bfb (patch)
treee282abf0f78b67af02ba98c02324172234c4264f /sbin
parent05b7edb11545a93980f9300d31c024ec63578702 (diff)
downloadFreeBSD-src-769c5f26dfd6a4c21bbcab3904a783bc04083bfb.zip
FreeBSD-src-769c5f26dfd6a4c21bbcab3904a783bc04083bfb.tar.gz
Fix an overflow or two and replace a while with a for.
Submitted by: Martin Blapp <mbr@imp.ch>
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mount_nfs/mount_nfs.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 588f14d..be1ddad 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -662,6 +662,7 @@ getnfsargs(spec, nfsargsp)
char *cp;
#endif
u_short tport;
+ size_t len;
static struct nfhret nfhret;
static char nam[MNAMELEN + 1];
@@ -685,21 +686,22 @@ getnfsargs(spec, nfsargsp)
* that some mountd implementations fail to remove the mount
* entries from their mountlist while unmounting.
*/
- speclen = strlen(spec);
- while (speclen > 1 && spec[speclen - 1] == '/') {
+ for (speclen = strlen(spec);
+ speclen > 1 && spec[speclen - 1] == '/';
+ speclen--)
spec[speclen - 1] = '\0';
- speclen--;
- }
if (strlen(hostp) + strlen(spec) + 1 > MNAMELEN) {
warnx("%s:%s: %s", hostp, spec, strerror(ENAMETOOLONG));
return (0);
}
-
/* Make both '@' and ':' notations equal */
- strcat(nam, hostp);
- strcat(nam, ":");
- strcat(nam, spec);
-
+ if (*hostp != '\0') {
+ len = strlen(hostp);
+ memmove(nam, hostp, len);
+ nam[len] = ':';
+ memmove(nam + len + 1, spec, speclen);
+ nam[len + speclen + 1] = '\0';
+ }
/*
* DUMB!! Until the mount protocol works on iso transport, we must
* supply both an iso and an inet address for the host.
OpenPOWER on IntegriCloud