I want to avoid having to use the GNU-extension memmem() when removing the
container entry. As mmap() does not guarantee us a \0-terminated string we
lseek() to the end of the file and write() a single terminating \0-byte to the
file and the mmap() the file. The terminating \0-byte will then be removed when
we ftruncate() the file after we have removed the entry. This allows us to use
standard string-handling functions like strstr(). We wrap strstr() in a while
loop to remove duplicate entries.

This patch is unnecessary if using memmem() does not bother anyone but me.
(Someone should also please check if my calculations for memmove() and
ftruncate() are correct.)

Christian Brauner (1):
  Ensure that mmap()ed memory is \0-terminated     lseek() to end of
    file and write() terminating \0-byte

 src/lxc/lxccontainer.c | 88 +++++++++++++++++++++++++++-----------------------
 1 file changed, 48 insertions(+), 40 deletions(-)

-- 
2.5.1

_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to