summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2006-06-23 14:38:33 +1000
committerNeil Brown <neilb@suse.de>2006-06-23 14:38:33 +1000
commit2e075a16da4963f54cd556403ca9e15a68de27fd (patch)
tree5e412d94ec623315a93286af4da52a2883dcd0a4 /support
parentff42180930a444cea7f19e55e2cd2bfe6d3f108b (diff)
downloadnfs-utils-2e075a16da4963f54cd556403ca9e15a68de27fd.tar.gz
nfs-utils-2e075a16da4963f54cd556403ca9e15a68de27fd.tar.xz
nfs-utils-2e075a16da4963f54cd556403ca9e15a68de27fd.zip
Fix various issues discovered by Coverity
Thanks to Michael Halcrow for finding them.
Diffstat (limited to 'support')
-rw-r--r--support/misc/mountpoint.c18
-rw-r--r--support/nfs/cacheio.c6
-rw-r--r--support/nfs/svc_socket.c2
3 files changed, 16 insertions, 10 deletions
diff --git a/support/misc/mountpoint.c b/support/misc/mountpoint.c
index 6d0f34e..2cf1324 100644
--- a/support/misc/mountpoint.c
+++ b/support/misc/mountpoint.c
@@ -20,15 +20,21 @@ is_mountpoint(char *path)
*/
char *dotdot;
struct stat stb, pstb;
+ int rv;
dotdot = malloc(strlen(path)+4);
+ if (!dotdot)
+ return 0;
strcat(strcpy(dotdot, path), "/..");
if (lstat(path, &stb) != 0 ||
lstat(dotdot, &pstb) != 0)
- return 0;
-
- if (stb.st_dev != pstb.st_dev
- || stb.st_ino == pstb.st_ino)
- return 1;
- return 0;
+ rv = 0;
+ else
+ if (stb.st_dev != pstb.st_dev ||
+ stb.st_ino == pstb.st_ino)
+ rv = 1;
+ else
+ rv = 0;
+ free(dotdot);
+ return rv;
}
diff --git a/support/nfs/cacheio.c b/support/nfs/cacheio.c
index d7ad429..3e868d8 100644
--- a/support/nfs/cacheio.c
+++ b/support/nfs/cacheio.c
@@ -259,9 +259,9 @@ cache_flush(int force)
"nfsd.export",
NULL
};
- stb.st_mtime = time(0);
- if (!force)
- stat(_PATH_ETAB, &stb);
+ if (force ||
+ stat(_PATH_ETAB, &stb) != 0)
+ stb.st_mtime = time(0);
sprintf(stime, "%ld\n", stb.st_mtime);
for (c=0; cachelist[c]; c++) {
diff --git a/support/nfs/svc_socket.c b/support/nfs/svc_socket.c
index 888c915..c41a1a3 100644
--- a/support/nfs/svc_socket.c
+++ b/support/nfs/svc_socket.c
@@ -42,7 +42,7 @@ svc_socket (u_long number, int type, int protocol, int reuse)
socklen_t len = sizeof (struct sockaddr_in);
char rpcdata [1024], servdata [1024];
struct rpcent rpcbuf, *rpcp;
- struct servent servbuf, *servp;
+ struct servent servbuf, *servp = NULL;
int sock, ret;
const char *proto = protocol == IPPROTO_TCP ? "tcp" : "udp";