If a corruption occurs, save buffers into files
authorSimon Guinot <simon.guinot@seagate.com>
Wed, 28 Jan 2015 16:31:57 +0000 (17:31 +0100)
committerSimon Guinot <simon.guinot@seagate.com>
Wed, 28 Jan 2015 16:31:57 +0000 (17:31 +0100)
With this patch, both the reference and corrupted buffers are saved
info files when a corruption is detected.

net.c

diff --git a/net.c b/net.c
index 3bf3a67..653bea7 100644 (file)
--- a/net.c
+++ b/net.c
@@ -407,6 +407,12 @@ static int recv_data_messages(int sock, struct netsum_ctrl *ctrl,
                if (use_memcmp && !memcmp(buff, template, ctrl->size))
                        continue;
                if (!buffer_is_valid(buff, ctrl->size, true)) {
+                       fprintf(stdout,
+                               "Reference buffer stored in file: ref\n", "ref");
+                       fprintf(stdout,
+                               "Corrupted buffer stored in file: err\n", "err");
+                       write_buffer_to_file("ref", buff, ctrl->size);
+                       write_buffer_to_file("err", template, ctrl->size);
                        ret = -1;
                        goto err_free;
                }