/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "media/ShmemUtil.h"

namespace android {
namespace media {

bool validateSharedFileRegion(const SharedFileRegion& shmem) {
    // FD must be valid.
    if (shmem.fd.get() < 0) {
        return false;
    }

    // Size and offset must be non-negative.
    if (shmem.size < 0 || shmem.offset < 0) {
        return false;
    }

    uint64_t size = shmem.size;
    uint64_t offset = shmem.offset;

    // Must not wrap.
    if (offset > offset + size) {
        return false;
    }

    return true;
}

}  // namespace media
}  // namespace android
