aboutsummaryrefslogtreecommitdiffstats
path: root/vespalog/src/vespa/log/control-file.h
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahoo-inc.com>2016-11-11 11:40:18 +0100
committerArne H Juul <arnej@yahoo-inc.com>2016-11-11 11:40:18 +0100
commitd12a79dfeb505691ecf28604814e88b14bca2b65 (patch)
treec7dd004c060a180f0c8c210c843948629827c020 /vespalog/src/vespa/log/control-file.h
parent13bcac77f9311930bb3a4bcfa33f2d4799563bab (diff)
ensure returned Component refers to valid memory
* we have seen some core dumps in logctl when using the mmap'ed levels inside a Component. Add extra checks to ensure we stay inside the actual file.
Diffstat (limited to 'vespalog/src/vespa/log/control-file.h')
-rw-r--r--vespalog/src/vespa/log/control-file.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/vespalog/src/vespa/log/control-file.h b/vespalog/src/vespa/log/control-file.h
index d0fb211e202..886f38791ba 100644
--- a/vespalog/src/vespa/log/control-file.h
+++ b/vespalog/src/vespa/log/control-file.h
@@ -17,6 +17,7 @@ public:
enum Mode { READONLY, READWRITE, CREATE };
private:
Lock _fileBacking;
+ int _fileSize;
enum Mode _mode;
char *_fileName;
void ensureHeader();
@@ -56,6 +57,7 @@ public:
~ControlFile();
unsigned int *getLevels(const char *name);
void ensureComponent(const char *pattern);
+ bool insideFile(char *p) { return (p >= _mapBase) && (p < _mapBase + _fileSize); }
static unsigned int *defaultLevels();