LCOV - code coverage report
Current view: top level - include/sys - socket.h (source / functions) Hit Total Coverage
Test: cleaned-coverage.info Lines: 8 12 66.7 %
Date: 2024-10-21 13:06:23 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2015-2016 Dimitris Papastamos <sin@2f30.org>
       3             :  * Copyright (C) 2022 q66 <q66@chimera-linux.org>
       4             :  *
       5             :  * Permission to use, copy, modify, and/or distribute this software for any
       6             :  * purpose with or without fee is hereby granted.
       7             :  *
       8             :  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
       9             :  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      10             :  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
      11             :  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
      12             :  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
      13             :  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
      14             :  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      15             :  */
      16             : 
      17             : #ifndef _FORTIFY_SYS_SOCKET_H
      18             : #define _FORTIFY_SYS_SOCKET_H
      19             : 
      20             : #if !defined(__cplusplus) && !defined(__clang__)
      21             : __extension__
      22             : #endif
      23             : #include_next <sys/socket.h>
      24             : 
      25             : #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0
      26             : #include "../fortify-headers.h"
      27             : 
      28             : #ifdef __cplusplus
      29             : extern "C" {
      30             : #endif
      31             : 
      32             : #undef recv
      33             : #undef recvfrom
      34             : #undef send
      35             : #undef sendto
      36             : 
      37             : __fh_access(write_only, 2, 3)
      38             : _FORTIFY_FN(recv) ssize_t recv(int __f, void * _FORTIFY_POS0 __s, size_t __n,
      39             :                                int __fl)
      40             : {
      41             :         __fh_size_t __b = __fh_bos(__s, 0);
      42             : 
      43           1 :         if (__n > __b)
      44           2 :                 __builtin_trap();
      45           0 :         return __orig_recv(__f, __s, __n, __fl);
      46             : }
      47             : 
      48             : __fh_access(write_only, 2, 3)
      49             : _FORTIFY_FN(recvfrom) ssize_t recvfrom(int __f, void * _FORTIFY_POS0 __s,
      50             :                                        size_t __n, int __fl,
      51             :                                        struct sockaddr *__a, socklen_t *__l)
      52             : {
      53             :         __fh_size_t __b = __fh_bos(__s, 0);
      54             : 
      55           1 :         if (__n > __b)
      56           2 :                 __builtin_trap();
      57           0 :         return __orig_recvfrom(__f, __s, __n, __fl, __a, __l);
      58             : }
      59             : 
      60             : __fh_access(read_only, 2, 3)
      61             : _FORTIFY_FN(send) ssize_t send(int __f, const void * _FORTIFY_POS0 __s,
      62             :                                size_t __n, int __fl)
      63             : {
      64             :         __fh_size_t __b = __fh_bos(__s, 0);
      65             : 
      66           1 :         if (__n > __b)
      67           2 :                 __builtin_trap();
      68           0 :         return __orig_send(__f, __s, __n, __fl);
      69             : }
      70             : 
      71             : __fh_access(read_only, 2, 3)
      72             : _FORTIFY_FN(sendto) ssize_t sendto(int __f, const void * _FORTIFY_POS0 __s,
      73             :                                    size_t __n, int __fl,
      74             :                                    const struct sockaddr *__a, socklen_t __l)
      75             : {
      76             :         __fh_size_t __b = __fh_bos(__s, 0);
      77             : 
      78           1 :         if (__n > __b)
      79           2 :                 __builtin_trap();
      80           0 :         return __orig_sendto(__f, __s, __n, __fl, __a, __l);
      81             : }
      82             : 
      83             : #ifdef __cplusplus
      84             : }
      85             : #endif
      86             : 
      87             : #endif
      88             : 
      89             : #endif

Generated by: LCOV version 1.14