capture-writer: ftruncate() when creating capture

We risk overwriting existing data leaving our file in a somewhat broken
state. So first ftruncate() to zero so we are starting from scratch.
This commit is contained in:
Christian Hergert
2016-10-16 13:23:16 -07:00
parent cca23054fd
commit 71e1134cbc

View File

@ -375,6 +375,9 @@ sp_capture_writer_new_from_fd (int fd,
g_assert (fd != -1);
g_assert (buffer_size % getpagesize() == 0);
if (ftruncate (fd, 0) != 0)
return NULL;
self = g_new0 (SpCaptureWriter, 1);
self->ref_count = 1;
self->fd = fd;