summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-18 18:52:36 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-03-19 10:55:21 -0400
commit0f53eb0d3ffc10265e748915b2df1411dbce7af0 (patch)
treed88c729f5ae025291c60186aa37991905fffc2d7
parent244091b2071f18875c448a1df65d34825fef1167 (diff)
downloadsssd-0f53eb0d3ffc10265e748915b2df1411dbce7af0.tar.gz
sssd-0f53eb0d3ffc10265e748915b2df1411dbce7af0.tar.xz
sssd-0f53eb0d3ffc10265e748915b2df1411dbce7af0.zip
Fix invalid read cause by premature free of tmpctx
-rw-r--r--src/monitor/monitor.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 0ba335467..c6af60612 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1344,8 +1344,7 @@ static void process_config_file(struct tevent_context *ev,
buf = talloc_size(tmp_ctx, event_size);
if (!buf) {
- talloc_free(tmp_ctx);
- return;
+ goto done;
}
total_len = 0;
@@ -1354,8 +1353,7 @@ static void process_config_file(struct tevent_context *ev,
event_size-total_len);
if (len == -1 && errno != EINTR) {
DEBUG(0, ("Critical error reading inotify file descriptor.\n"));
- talloc_free(tmp_ctx);
- return;
+ goto done;
}
total_len += len;
}
@@ -1368,23 +1366,19 @@ static void process_config_file(struct tevent_context *ev,
*/
name = talloc_size(tmp_ctx, len);
if (!name) {
- talloc_free(tmp_ctx);
- return;
+ goto done;
}
total_len = 0;
while (total_len < in_event->len) {
len = read(file_ctx->mt_ctx->inotify_fd, &name, in_event->len);
if (len == -1 && errno != EINTR) {
DEBUG(0, ("Critical error reading inotify file descriptor.\n"));
- talloc_free(tmp_ctx);
- return;
+ goto done;
}
total_len += len;
}
}
- talloc_free(tmp_ctx);
-
for (cb = file_ctx->callbacks; cb; cb = cb->next) {
if (cb->wd == in_event->wd) {
break;
@@ -1392,7 +1386,7 @@ static void process_config_file(struct tevent_context *ev,
}
if (!cb) {
DEBUG(0, ("Unknown watch descriptor\n"));
- return;
+ goto done;
}
if (in_event->mask & IN_IGNORED) {
@@ -1413,7 +1407,7 @@ static void process_config_file(struct tevent_context *ev,
DEBUG(0, ("Could not restore inotify watch. Quitting!\n"));
close(file_ctx->mt_ctx->inotify_fd);
kill(getpid(), SIGTERM);
- return;
+ goto done;
}
rw_ctx->cb = cb;
rw_ctx->file_ctx = file_ctx;
@@ -1424,12 +1418,15 @@ static void process_config_file(struct tevent_context *ev,
close(file_ctx->mt_ctx->inotify_fd);
kill(getpid(), SIGTERM);
}
- return;
+ goto done;
}
/* Tell the monitor to signal the children */
cb->fn(file_ctx, cb->filename);
file_ctx->needs_update = 0;
+
+done:
+ talloc_free(tmp_ctx);
}
static void rewatch_config_file(struct tevent_context *ev,