Skip to content
Snippets Groups Projects
Commit a6913f97 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Inotify: Minor code cleanup. Potential fix for [CID 1325796].

parent 1be20a1b
No related branches found
No related tags found
No related merge requests found
......@@ -384,14 +384,18 @@ PIKECLASS _Instance {
}
while (THIS->buf.s->len >=
(off + (ptrdiff_t)sizeof(struct inotify_event))) {
/* NB: Assumes that e->len has a valid alignment
* for the struct. This could cause problems
* on non-x86 systems and injected data.
*/
struct inotify_event *e = (void *)(THIS->buf.s->str + off);
const char *path = (char *)(e + 1);
if ((off + (ptrdiff_t)sizeof(struct inotify_event) + e->len) >
THIS->buf.s->len) {
ptrdiff_t new_off = off + sizeof(struct inotify_event) + e->len;
if (new_off > THIS->buf.s->len) {
/* Not enough data for the filename yet. */
break;
}
off += sizeof(struct inotify_event) + e->len;
off = new_off;
push_int(e->wd);
push_int(e->mask);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment