Skip to content

Commit

Permalink
Check sockaddr size in inet_pton
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 333821843
Change-Id: Ie0b694f1edd3f7a4a3de6df964d68566961accf6
  • Loading branch information
kongoshuu committed Sep 25, 2020
1 parent 6ff3b77 commit 8fed5e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions asylo/platform/host_call/trusted/host_calls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,16 @@ int enc_untrusted_inet_pton(int af, const char *src, void *dst) {
auto klinux_addr_buffer = output.next();
size_t max_size = 0;
if (af == AF_INET) {
if (klinux_addr_buffer.size() != sizeof(klinux_in_addr)) {
::asylo::primitives::TrustedPrimitives::BestEffortAbort(
"enc_untrusted_inet_pton: unexpected output size");
}
max_size = sizeof(struct in_addr);
} else if (af == AF_INET6) {
if (klinux_addr_buffer.size() != sizeof(klinux_in6_addr)) {
::asylo::primitives::TrustedPrimitives::BestEffortAbort(
"enc_untrusted_inet_pton: unexpected output size");
}
max_size = sizeof(struct in6_addr);
}
memcpy(dst, klinux_addr_buffer.data(),
Expand Down

0 comments on commit 8fed5e3

Please sign in to comment.