|
|
bc9fd4 |
From fd2e952319c748e1c7babb1db97b371ebf6748a9 Mon Sep 17 00:00:00 2001
|
|
|
bc9fd4 |
From: Alice J Mitchell <ajmitchell@redhat.com>
|
|
|
bc9fd4 |
Date: Mon, 29 Jul 2019 15:47:40 +0100
|
|
|
bc9fd4 |
Subject: [PATCH] Fix the error handling if the lseek fails
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
The error case when lseek returns a negative value was not correctly handled,
|
|
|
bc9fd4 |
and the error cleanup routine was potentially leaking memory also.
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
Signed-off-by: Alice J Mitchell <ajmitchell@redhat.com>
|
|
|
bc9fd4 |
---
|
|
|
bc9fd4 |
support/nfs/conffile.c | 8 +++++++-
|
|
|
bc9fd4 |
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
|
|
|
bc9fd4 |
index b6400be..6ba8a35 100644
|
|
|
bc9fd4 |
--- a/support/nfs/conffile.c
|
|
|
bc9fd4 |
+++ b/support/nfs/conffile.c
|
|
|
bc9fd4 |
@@ -500,7 +500,7 @@ conf_readfile(const char *path)
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
if ((stat (path, &sb) == 0) || (errno != ENOENT)) {
|
|
|
bc9fd4 |
char *new_conf_addr = NULL;
|
|
|
bc9fd4 |
- size_t sz = sb.st_size;
|
|
|
bc9fd4 |
+ off_t sz;
|
|
|
bc9fd4 |
int fd = open (path, O_RDONLY, 0);
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
if (fd == -1) {
|
|
|
bc9fd4 |
@@ -517,6 +517,11 @@ conf_readfile(const char *path)
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
/* only after we have the lock, check the file size ready to read it */
|
|
|
bc9fd4 |
sz = lseek(fd, 0, SEEK_END);
|
|
|
bc9fd4 |
+ if (sz < 0) {
|
|
|
bc9fd4 |
+ xlog_warn("conf_readfile: unable to determine file size: %s",
|
|
|
bc9fd4 |
+ strerror(errno));
|
|
|
bc9fd4 |
+ goto fail;
|
|
|
bc9fd4 |
+ }
|
|
|
bc9fd4 |
lseek(fd, 0, SEEK_SET);
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
new_conf_addr = malloc(sz+1);
|
|
|
bc9fd4 |
@@ -2162,6 +2167,7 @@ conf_write(const char *filename, const char *section, const char *arg,
|
|
|
bc9fd4 |
ret = 0;
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
cleanup:
|
|
|
bc9fd4 |
+ flush_outqueue(&inqueue, NULL);
|
|
|
bc9fd4 |
flush_outqueue(&outqueue, NULL);
|
|
|
bc9fd4 |
|
|
|
bc9fd4 |
if (buff)
|
|
|
bc9fd4 |
--
|
|
|
bc9fd4 |
1.8.3.1
|
|
|
bc9fd4 |
|