If a memory mapped file does not end with a newline, do not check for
its existence. Accessing *end would lead to an out of boundary read.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
rec->mesg_size = end - begin;
}
- /* Don't count \n from the last message to the message size */
- if (*end != '\n' && *(end - 1) == '\n')
- rec->mesg_size--;
-
rec->next_size -= end - rec->next;
rec->next = rec->next_size > 0 ? end + 1 : NULL;
if (rec->next_size > 0)
rec->next_size--;
+ /* Don't count \n from the last message to the message size */
+ if ((!rec->next || *end != '\n') && *(end - 1) == '\n')
+ rec->mesg_size--;
+
return 0;
}