Skip to content

Commit

Permalink
socket: using error return (envoyproxy#31853)
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk authored Jan 17, 2024
1 parent 2e36903 commit d418165
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
4 changes: 1 addition & 3 deletions source/common/network/socket_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ Api::SysCallIntResult SocketImpl::bind(Network::Address::InstanceConstSharedPtr
if (pipe->mode() != 0 && !abstract_namespace && bind_result.return_value_ == 0) {
auto set_permissions = Api::OsSysCallsSingleton::get().chmod(pipe_sa->sun_path, pipe->mode());
if (set_permissions.return_value_ != 0) {
throwEnvoyExceptionOrPanic(fmt::format("Failed to create socket with mode {}: {}",
std::to_string(pipe->mode()),
errorDetails(set_permissions.errno_)));
return set_permissions;
}
}
return bind_result;
Expand Down
2 changes: 1 addition & 1 deletion test/common/network/address_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ TEST(PipeInstanceTest, PermissionFail) {

EXPECT_CALL(os_sys_calls, bind(_, _, _)).WillOnce(Return(Api::SysCallIntResult{0, 0}));
EXPECT_CALL(os_sys_calls, chmod(_, _)).WillOnce(Return(Api::SysCallIntResult{-1, 0}));
EXPECT_THROW_WITH_REGEX(sock.bind(address), EnvoyException, "Failed to create socket with mode");
EXPECT_NE(sock.bind(address).return_value_, 0);
}

TEST(PipeInstanceTest, AbstractNamespacePermission) {
Expand Down
1 change: 0 additions & 1 deletion tools/code_format/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ paths:
- source/common/network/address_impl.cc
- source/common/network/utility.cc
- source/common/network/dns_resolver/dns_factory_util.cc
- source/common/network/socket_impl.cc
- source/common/ssl/tls_certificate_config_impl.cc
- source/common/formatter/http_specific_formatter.cc
- source/common/formatter/stream_info_formatter.h
Expand Down

0 comments on commit d418165

Please sign in to comment.