[SSSD] [PATCH] Fix a potential memory violation
Sumit Bose
sbose at redhat.com
Thu Apr 22 10:15:53 UTC 2010
Hi,
by chance I came across this short read loop.
bye,
Sumit
-------------- next part --------------
From 3793c57daf3599f1e023ecb9e5d7a2bf9043516e Mon Sep 17 00:00:00 2001
From: Sumit Bose <sbose at redhat.com>
Date: Thu, 22 Apr 2010 11:44:46 +0200
Subject: [PATCH] Fix a potential memory violation
If read() returns with errno set to EINTR -1 is added to total_len.
---
src/monitor/monitor.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 0a98d09..c7997e4 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -1371,7 +1371,8 @@ static void process_config_file(struct tevent_context *ev,
while (total_len < event_size) {
len = read(file_ctx->mt_ctx->inotify_fd, buf+total_len,
event_size-total_len);
- if (len == -1 && errno != EINTR) {
+ if (len == -1) {
+ if (errno == EINTR) continue;
DEBUG(0, ("Critical error reading inotify file descriptor.\n"));
goto done;
}
@@ -1391,7 +1392,8 @@ static void process_config_file(struct tevent_context *ev,
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) {
+ if (len == -1) {
+ if (errno == EINTR) continue;
DEBUG(0, ("Critical error reading inotify file descriptor.\n"));
goto done;
}
--
1.6.6.1
More information about the sssd-devel
mailing list