{
int fd;
int wd;
- int i = 0;
- int event_size;
+ ssize_t i = 0;
+ ssize_t event_size;
ssize_t size;
unsigned char buf[128];
struct inotify_event *event;
ERR("Wait for the server to be ready.[fd: %d, wd: %d", fd, wd);
size = read(fd, buf, sizeof(buf));
- while ((i + (int)sizeof(struct inotify_event)) <= (int)size)
+ while ((i + sizeof(struct inotify_event)) <= size)
{
event = (struct inotify_event *)&buf[i];
event_size = sizeof(struct inotify_event) + event->len;
- if ((event_size + i) > size) break;
+ if ((event_size + i) > size || (event_size + i) <= 0) break;
i += event_size;
if (event->mask & IN_CREATE | event->mask & IN_MODIFY) break;
}