|
@@ -333,9 +333,13 @@ int rtcGetLocalAddress(int pc, char *buffer, int size) {
|
|
if (!buffer)
|
|
if (!buffer)
|
|
throw std::invalid_argument("Unexpected null pointer");
|
|
throw std::invalid_argument("Unexpected null pointer");
|
|
|
|
|
|
|
|
+ if (size <= 0)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
if (auto addr = peerConnection->localAddress()) {
|
|
if (auto addr = peerConnection->localAddress()) {
|
|
|
|
+ const char *data = addr->data();
|
|
size = std::min(size_t(size - 1), addr->size());
|
|
size = std::min(size_t(size - 1), addr->size());
|
|
- std::copy(addr->data(), addr->data() + size, buffer);
|
|
|
|
|
|
+ std::copy(data, data + size, buffer);
|
|
buffer[size] = '\0';
|
|
buffer[size] = '\0';
|
|
return size + 1;
|
|
return size + 1;
|
|
}
|
|
}
|
|
@@ -349,9 +353,13 @@ int rtcGetRemoteAddress(int pc, char *buffer, int size) {
|
|
if (!buffer)
|
|
if (!buffer)
|
|
throw std::invalid_argument("Unexpected null pointer");
|
|
throw std::invalid_argument("Unexpected null pointer");
|
|
|
|
|
|
|
|
+ if (size <= 0)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
if (auto addr = peerConnection->remoteAddress()) {
|
|
if (auto addr = peerConnection->remoteAddress()) {
|
|
|
|
+ const char *data = addr->data();
|
|
size = std::min(size_t(size - 1), addr->size());
|
|
size = std::min(size_t(size - 1), addr->size());
|
|
- std::copy(addr->data(), addr->data() + size, buffer);
|
|
|
|
|
|
+ std::copy(data, data + size, buffer);
|
|
buffer[size] = '\0';
|
|
buffer[size] = '\0';
|
|
return size + 1;
|
|
return size + 1;
|
|
}
|
|
}
|
|
@@ -365,15 +373,15 @@ int rtcGetDataChannelLabel(int dc, char *buffer, int size) {
|
|
if (!buffer)
|
|
if (!buffer)
|
|
throw std::invalid_argument("Unexpected null pointer");
|
|
throw std::invalid_argument("Unexpected null pointer");
|
|
|
|
|
|
- if (size >= 0) {
|
|
|
|
- string label = dataChannel->label();
|
|
|
|
- size = std::min(size_t(size - 1), label.size());
|
|
|
|
- std::copy(label.data(), label.data() + size, buffer);
|
|
|
|
- buffer[size] = '\0';
|
|
|
|
- return size + 1;
|
|
|
|
- } else {
|
|
|
|
|
|
+ if (size <= 0)
|
|
return 0;
|
|
return 0;
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ string label = dataChannel->label();
|
|
|
|
+ const char *data = label.data();
|
|
|
|
+ size = std::min(size_t(size - 1), label.size());
|
|
|
|
+ std::copy(data, data + size, buffer);
|
|
|
|
+ buffer[size] = '\0';
|
|
|
|
+ return size + 1;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|