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);