Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Commit 4853fda

Browse files
authored
Clean memory for password before returning to system. (#879)
1 parent 1a139ab commit 4853fda

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

source/agent/addons/quic/QuicTransportServer.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "QuicTransportServer.h"
88
#include "QuicFactory.h"
99
#include "QuicTransportStream.h"
10+
#include "Utils.h"
1011
#include "owt/quic/quic_transport_factory.h"
1112
#include "owt/quic/quic_transport_session_interface.h"
1213

@@ -55,6 +56,7 @@ NAN_METHOD(QuicTransportServer::newInstance)
5556
v8::String::Utf8Value pfxPath(Nan::To<v8::String>(info[1]).ToLocalChecked());
5657
v8::String::Utf8Value password(Nan::To<v8::String>(info[2]).ToLocalChecked());
5758
QuicTransportServer* obj = new QuicTransportServer(port, *pfxPath, *password);
59+
owt_base::Utils::ZeroMemory(*password, password.length());
5860
obj->Wrap(info.This());
5961
uv_async_init(uv_default_loop(), &obj->m_asyncOnConnection, &QuicTransportServer::onConnectionCallback);
6062
info.GetReturnValue().Set(info.This());

source/agent/addons/quic/binding.gyp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
'QuicTransportConnection.cc',
1010
'../../../core/owt_base/MediaFramePipeline.cpp',
1111
'../../../core/owt_base/MediaFrameMulticaster.cpp',
12+
'../../../core/owt_base/Utils.cc',
1213
],
1314
'defines':[
1415
'OWT_ENABLE_QUIC=1',

source/core/owt_base/Utils.cc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (C) <2021> Intel Corporation
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
/*
6+
* Copyright 2017 The WebRTC Project Authors. All rights reserved.
7+
*
8+
* Use of this source code is governed by a BSD-style license
9+
* that can be found in the LICENSE file in the root of the source
10+
* tree. An additional intellectual property rights grant can be found
11+
* in the file PATENTS. All contributing project authors may
12+
* be found in the AUTHORS file in the root of the source tree.
13+
*/
14+
15+
#include <cstring>
16+
17+
#include <Utils.h>
18+
19+
namespace owt_base {
20+
21+
void Utils::ZeroMemory(void* ptr, size_t len)
22+
{
23+
// Implementation of this method is copied from https://source.chromium.org/chromium/chromium/src/+/master:third_party/webrtc/rtc_base/zero_memory.cc;drc=5b32f238f3a20d00122b2335d9cf7faa9d29c2dd;l=23.
24+
#ifdef WIN32
25+
SecureZeroMemory(ptr, len);
26+
#else
27+
memset(ptr, 0, len);
28+
__asm__ __volatile__(""
29+
:
30+
: "r"(ptr)
31+
: "memory");
32+
#endif
33+
}
34+
}

source/core/owt_base/Utils.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (C) <2021> Intel Corporation
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
#ifndef UTILS_H
6+
#define UTILS_H
7+
8+
#include <cstddef>
9+
10+
namespace owt_base {
11+
12+
class Utils {
13+
public:
14+
// Fill memory with zeros.
15+
static void ZeroMemory(void* ptr, size_t len);
16+
};
17+
18+
}
19+
#endif

0 commit comments

Comments
 (0)