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

Commit c1d56ee6 authored by Kevin Rocard's avatar Kevin Rocard Committed by android-build-merger
Browse files

Fix potential missing '\0' when wrapping to legacy

am: 2b275704

Change-Id: Ie1ba5bdb79310bbb00a5b63690f2d2edebd4001d
parents 48bc80b2 2b275704
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -296,8 +296,8 @@ void HidlUtils::audioPortToHal(const AudioPort& port, struct audio_port* halPort
    halPort->id = port.id;
    halPort->id = port.id;
    halPort->role = static_cast<audio_port_role_t>(port.role);
    halPort->role = static_cast<audio_port_role_t>(port.role);
    halPort->type = static_cast<audio_port_type_t>(port.type);
    halPort->type = static_cast<audio_port_type_t>(port.type);
    memcpy(halPort->name, port.name.c_str(),
    strncpy(halPort->name, port.name.c_str(), AUDIO_PORT_MAX_NAME_LEN);
           std::min(port.name.size(), static_cast<size_t>(AUDIO_PORT_MAX_NAME_LEN)));
    halPort->name[AUDIO_PORT_MAX_NAME_LEN - 1] = '\0';
    halPort->num_sample_rates =
    halPort->num_sample_rates =
        std::min(port.sampleRates.size(), static_cast<size_t>(AUDIO_PORT_MAX_SAMPLING_RATES));
        std::min(port.sampleRates.size(), static_cast<size_t>(AUDIO_PORT_MAX_SAMPLING_RATES));
    for (size_t i = 0; i < halPort->num_sample_rates; ++i) {
    for (size_t i = 0; i < halPort->num_sample_rates; ++i) {