summaryrefslogtreecommitdiffstats
path: root/src/account
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2013-11-04 13:45:24 +0100
committerRadek Novacek <rnovacek@redhat.com>2013-11-04 17:14:22 +0100
commit23a5e2d1500c537e260da1b9c64e9ea82baf1345 (patch)
treea23380a213eb2ac5c2622e999d1057a13bfa6517 /src/account
parent365cf4932b7e1ac172c30cb5f042e062a0470435 (diff)
downloadopenlmi-providers-23a5e2d1500c537e260da1b9c64e9ea82baf1345.tar.gz
openlmi-providers-23a5e2d1500c537e260da1b9c64e9ea82baf1345.tar.xz
openlmi-providers-23a5e2d1500c537e260da1b9c64e9ea82baf1345.zip
Fix coverity issues
Diffstat (limited to 'src/account')
-rw-r--r--src/account/indication_common.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/account/indication_common.c b/src/account/indication_common.c
index 22391e3..88d16a0 100644
--- a/src/account/indication_common.c
+++ b/src/account/indication_common.c
@@ -159,14 +159,20 @@ bool watcher(AccountIndication *ind, void **data)
do {
int len = 0, i = 0;
- if ((len = read(ind->inotify_fd, buffer, BUF_LEN)) < 0) {
+ if ((len = read(ind->inotify_fd, buffer, BUF_LEN)) < 0 || len > (int) BUF_LEN) {
warn("account watcher: error reading from inotify fd: %s", strerror(errno));
watcher_destroy(ind);
watcher_init(ind);
return false;
}
- while (i < len) {
+ while (i + (ssize_t) EVENT_SIZE < len) {
struct inotify_event *event = (struct inotify_event *) &buffer[i];
+ if (i + (ssize_t) EVENT_SIZE + event->len >= len) {
+ error("Unable to create watcher, inotify initialization failed");
+ watcher_destroy(ind);
+ watcher_init(ind);
+ return false;
+ }
switch (event->mask) {
case IN_MODIFY:
case IN_CLOSE_WRITE: