From 65caaab77bb1fd4bcc7de119a40583d9c1cc067c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 13 Feb 2017 08:22:24 +0200 Subject: [PATCH] Fix maxavro block verification errors An error was logged when the end of file was reached. The error should only be logged when a partial sync marker is read and the end of file has not been reached. --- avro/maxavro_file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/avro/maxavro_file.c b/avro/maxavro_file.c index 7c5083489..07225a32b 100644 --- a/avro/maxavro_file.c +++ b/avro/maxavro_file.c @@ -12,6 +12,7 @@ */ #include "maxavro.h" +#include "skygw_utils.h" #include #include #include @@ -49,11 +50,12 @@ bool maxavro_verify_block(MAXAVRO_FILE *file) int rc = fread(sync, 1, SYNC_MARKER_SIZE, file->file); if (rc != SYNC_MARKER_SIZE) { - if (rc == -1) + if (ferror(file->file)) { - MXS_ERROR("Failed to read file: %d %s", errno, strerror(errno)); + char err[STRERROR_BUFLEN]; + MXS_ERROR("Failed to read file: %d %s", errno, strerror_r(errno, err, sizeof(err))); } - else + else if (rc > 0 || !feof(file->file)) { MXS_ERROR("Short read when reading sync marker. Read %d bytes instead of %d", rc, SYNC_MARKER_SIZE);