From fdcbd38dc14d13e9aa463f28423cc0cc33c2768b Mon Sep 17 00:00:00 2001 From: Sivaprasad Tummala Date: Sat, 31 Jul 2021 21:38:19 +0530 Subject: vcl: fix ldp for __recv_chk socket calls add ldp support for handling __recv_chk socket calls. Type: fix Signed-off-by: Sivaprasad Tummala Change-Id: I33221c465ac607bc665fcba500dd399a56b32df6 --- src/vcl/ldp.c | 9 +++++++++ src/vcl/ldp_glibc_socket.h | 8 ++++++++ 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c index 5edb935006f..de886ca95b9 100644 --- a/src/vcl/ldp.c +++ b/src/vcl/ldp.c @@ -1530,6 +1530,15 @@ recv (int fd, void *buf, size_t n, int flags) return size; } +ssize_t +__recv_chk (int fd, void *buf, size_t n, size_t buflen, int flags) +{ + if (n > buflen) + return -1; + + return recv (fd, buf, n, flags); +} + static int ldp_vls_sendo (vls_handle_t vlsh, const void *buf, size_t n, int flags, __CONST_SOCKADDR_ARG addr, socklen_t addr_len) diff --git a/src/vcl/ldp_glibc_socket.h b/src/vcl/ldp_glibc_socket.h index 0890a644488..95fb7c81094 100644 --- a/src/vcl/ldp_glibc_socket.h +++ b/src/vcl/ldp_glibc_socket.h @@ -163,6 +163,14 @@ extern ssize_t sendfile (int __out_fd, int __in_fd, off_t * __offset, __THROW. */ extern ssize_t recv (int __fd, void *__buf, size_t __n, int __flags); +/* Read N bytes into BUF from socket FD with buffer overflow checking. + Returns the number read or -1 for errors. + + This function is a cancellation point and therefore not marked with + __THROW. */ +extern ssize_t __recv_chk (int fd, void *buf, size_t n, size_t buflen, + int flags); + /* Send N bytes of BUF on socket FD to peer at address ADDR (which is ADDR_LEN bytes long). Returns the number sent, or -1 for errors. -- cgit 1.2.3-korg