Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b452560 authored by Steven Moreland's avatar Steven Moreland Committed by Automerger Merge Worker
Browse files

Merge "libbinder_ndk: log on null non-@nullable fd/binder" am: 5605b245 am: 4482b41b

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1535565

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I11859ab4d422775c0bb5c59c235050656c753a54
parents b60c07df 4482b41b
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -27,19 +27,12 @@
#pragma once

#include <android/binder_ibinder.h>
#include <android/binder_internal_logging.h>
#include <android/binder_parcel.h>
#include <android/binder_status.h>

#include <assert.h>

// defined differently by liblog
#pragma push_macro("LOG_PRI")
#ifdef LOG_PRI
#undef LOG_PRI
#endif
#include <syslog.h>
#pragma pop_macro("LOG_PRI")

#include <unistd.h>
#include <cstddef>
#include <string>
+38 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

/**
 * @addtogroup NdkBinder
 * @{
 */

/**
 * @file binder_internal_logging.h
 * @brief This provides the ability to use syslog from binder headers, since
 * other logging functionality might be inaccessable.
 */

#pragma once

// defined differently by liblog
#pragma push_macro("LOG_PRI")
#ifdef LOG_PRI
#undef LOG_PRI
#endif
#include <syslog.h>
#pragma pop_macro("LOG_PRI")

/** @} */
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#pragma once

#include <android/binder_auto_utils.h>
#include <android/binder_internal_logging.h>
#include <android/binder_parcel.h>

#include <optional>
@@ -179,6 +180,7 @@ static inline binder_status_t AParcel_readNullableStrongBinder(const AParcel* pa
static inline binder_status_t AParcel_writeRequiredStrongBinder(AParcel* parcel,
                                                                const SpAIBinder& binder) {
    if (binder.get() == nullptr) {
        syslog(LOG_ERR, "Passing null binder object as non-@nullable AIDL IBinder");
        return STATUS_UNEXPECTED_NULL;
    }
    return AParcel_writeStrongBinder(parcel, binder.get());
@@ -228,6 +230,7 @@ static inline binder_status_t AParcel_readNullableParcelFileDescriptor(const APa
static inline binder_status_t AParcel_writeRequiredParcelFileDescriptor(
        AParcel* parcel, const ScopedFileDescriptor& fd) {
    if (fd.get() < 0) {
        syslog(LOG_ERR, "Passing -1 file descriptor as non-@nullable AIDL ParcelFileDescriptor");
        return STATUS_UNEXPECTED_NULL;
    }
    return AParcel_writeParcelFileDescriptor(parcel, fd.get());