Skip to content

Commit

Permalink
Fix parameter validation for chrome.tcpServer.getInfo()
Browse files Browse the repository at this point in the history
In crrev.com/c/2961688 the implementation of this function was
simplified however an error was introduced where the parsed function
parameters were stored in a local variable but still accessed from an
instance variable.

This change removes the instance variable as it should have been in the
original change.

Bug: 1239520
Change-Id: I2a94ed1064ec85b6cddb0c80e751e46a1490b643
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3116443
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Auto-Submit: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#914932}
  • Loading branch information
reillyeon authored and Chromium LUCI CQ committed Aug 24, 2021
1 parent 6563fd8 commit 427152d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,15 @@ SocketsTcpServerGetInfoFunction::~SocketsTcpServerGetInfoFunction() = default;
ExtensionFunction::ResponseAction SocketsTcpServerGetInfoFunction::Work() {
std::unique_ptr<sockets_tcp_server::GetInfo::Params> params =
sockets_tcp_server::GetInfo::Params::Create(args());
EXTENSION_FUNCTION_VALIDATE(params_.get());
EXTENSION_FUNCTION_VALIDATE(params.get());

ResumableTCPServerSocket* socket = GetTcpSocket(params_->socket_id);
ResumableTCPServerSocket* socket = GetTcpSocket(params->socket_id);
if (!socket) {
return RespondNow(Error(kSocketNotFoundError));
}

sockets_tcp_server::SocketInfo socket_info =
CreateSocketInfo(params_->socket_id, socket);
CreateSocketInfo(params->socket_id, socket);
return RespondNow(
ArgumentList(sockets_tcp_server::GetInfo::Results::Create(socket_info)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ class SocketsTcpServerGetInfoFunction : public TCPServerSocketApiFunction {

// SocketApiFunction:
ResponseAction Work() override;

private:
std::unique_ptr<sockets_tcp_server::GetInfo::Params> params_;
};

class SocketsTcpServerGetSocketsFunction : public TCPServerSocketApiFunction {
Expand Down
5 changes: 5 additions & 0 deletions extensions/test/data/sockets_tcp_server/api/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ var testSocketListening = function() {
function onServerSocketCreate(socketInfo) {
console.log("Server socket created: sd=" + socketInfo.socketId);
socketId = socketInfo.socketId;
chrome.sockets.tcpServer.getInfo(socketId, onGetInfo);
}

function onGetInfo(socketInfo) {
chrome.test.assertEq(socketInfo.socketId, socketId);
chrome.sockets.tcpServer.listen(socketId, address, port, onListen);
}

Expand Down

0 comments on commit 427152d

Please sign in to comment.