diff options
author | Jim Meyering <meyering@redhat.com> | 2012-07-03 16:32:25 +0200 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-07-11 19:34:52 -0700 |
commit | f671ce6c6fa619b5cea2559495b4b21920f5de73 (patch) | |
tree | c7e4b2469e67cdd554b2b112085d6108be899856 /glusterfsd | |
parent | 7f2788675ba99193b7f18b3b9efbbbe3b5d0b2e5 (diff) |
glusterfsd: don't ignore tmpfile write failure (2x)
In both glusterfs_volfile_reconfigure and mgmt_getspec_cbk,
we fwrite to a temporary file, fflush the stream, and then
rewind and read from it. However, if either the fwrite or
fflush were to fail, we would have ignored a write failure
and would then read and process corrupt or incomplete input.
In each case, add a test of ferror so that we don't ignore
the write failure.
Found by inspection.
Change-Id: I8e84deb7d020a907870c9da2dde5c7371ce6ddb7
BUG: 789278
Signed-off-by: Jim Meyering <meyering@redhat.com>
Reviewed-on: http://review.gluster.com/3648
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'glusterfsd')
-rw-r--r-- | glusterfsd/src/glusterfsd-mgmt.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index be84167e..a98492fa 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -1473,6 +1473,9 @@ glusterfs_volfile_reconfigure (FILE *newvolfile_fp) } fwrite (oldvolfile, oldvollen, 1, oldvolfile_fp); fflush (oldvolfile_fp); + if (ferror (oldvolfile_fp)) { + goto out; + } oldvolfile_graph = glusterfs_graph_construct (oldvolfile_fp); @@ -1581,6 +1584,10 @@ mgmt_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count, fwrite (rsp.spec, size, 1, tmpfp); fflush (tmpfp); + if (ferror (tmpfp)) { + ret = -1; + goto out; + } /* Check if only options have changed. No need to reload the * volfile if topology hasn't changed. |