The transition from assert() to if() used the wrong comparaison making
the plugin to not work.
Fixes#10
Signed-off-by: David Goulet <dgoulet@riseup.net>
The overflow check should use SSIZE_MAX since the function returns the
chunk_size of size_t which in theory "could be" bigger but in practice
very unlikely.
Reported-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
Signed-off-by: David Goulet <dgoulet@riseup.net>
Properly handle the returned value of o_stream_send() so we make sure
the entire header was sent else error on that.
Reported-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
Signed-off-by: David Goulet <dgoulet@riseup.net>
In trees_ostream_send_chunk result of o_stream_send was not checked for
errors, and function always returns chunk_size it was given. Instead,
properly set the errno value from the parent stream and return an error.
Reported-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
Signed-off-by: David Goulet <dgoulet@riseup.net>
Tomasz Miąsko reported multiple issues with the trees_read_line_fd using
the trees_password_fd field. It is currently unused which used to be
used by the unit tests and dovadm in the Posteo scrambler plugin.
The issues are:
In trees_read_line_fd(), this check is bad:
if (bytes_read > MAXIMAL_PASSWORD_LENGTH)
Currently it is incorrect because when "bytes_read >
MAXIMAL_PASSWORD_LENGTH" is true, then buffer capacity is already
exceeded (or just right if you take into account one byte slack
allocated in str_new for terminating null). Moreover, the buffer
will be overrun by one more byte in "pointer[0] = 0;" after leaving
the loop.
Reported-by: Tomasz Miąsko <tomasz.miasko@gmail.com>
Signed-off-by: David Goulet <dgoulet@riseup.net>
Those files were useful for the old scrambler version made by Posteo
found here https://github.com/posteo/scrambler-plugin.
Now, the plugin has considerably changed thus all those aren't needed
anymore.
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
This version is extracted from the user data and put in the email header
but currently not used at all.
Future version will probably use it in order to do different actions
based on that value.
Currently version should be a 1.
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
At this commit, the plugin is in theory working correctly and has been
minimally tested.
Lots of work has been done in a debug branch and this commit merges all the
fixes at once as we are still consider in development at this stage.
Signed-off-by: David Goulet <dgoulet@ev0ke.net>