Commit c4bf0b4e authored by jan.koester's avatar jan.koester
Browse files

test

parent 16b881f8
Loading
Loading
Loading
Loading
Loading
+18 −0
Changes for src/backends/cluster.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -57,6 +57,24 @@ namespace authdb {
        return head.Revesion;
    }

    // Validate that all records in buffer have consistent offsets.
    // Returns false if any record's datasize would exceed the buffer.
    static bool bufferValid(const std::vector<uint8_t> &buf) {
        if (buf.size() < sizeof(AuthHeader))
            return buf.empty(); // empty is ok, too-small header is not

        size_t rd = sizeof(AuthHeader);
        while (rd + sizeof(AuthData::Record) <= buf.size()) {
            AuthData::Record rec;
            std::memcpy(&rec, buf.data() + rd, sizeof(AuthData::Record));
            rd += sizeof(AuthData::Record);
            if (rd + rec.datasize > buf.size())
                return false;
            rd += rec.datasize;
        }
        return true;
    }

    void ClusterBackend::fetchFromCluster() {
        if (!g_Cluster || !g_Cluster->isRunning())
            return;