LCOV - code coverage report
Current view: top level - usr/include/x86_64-linux-gnu/bits - unistd.h (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 10 14 71.4 %
Date: 2024-04-21 15:09:00 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /* Checking macros for unistd functions.
       2             :    Copyright (C) 2005-2022 Free Software Foundation, Inc.
       3             :    This file is part of the GNU C Library.
       4             : 
       5             :    The GNU C Library is free software; you can redistribute it and/or
       6             :    modify it under the terms of the GNU Lesser General Public
       7             :    License as published by the Free Software Foundation; either
       8             :    version 2.1 of the License, or (at your option) any later version.
       9             : 
      10             :    The GNU C Library is distributed in the hope that it will be useful,
      11             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :    Lesser General Public License for more details.
      14             : 
      15             :    You should have received a copy of the GNU Lesser General Public
      16             :    License along with the GNU C Library; if not, see
      17             :    <https://www.gnu.org/licenses/>.  */
      18             : 
      19             : #ifndef _UNISTD_H
      20             : # error "Never include <bits/unistd.h> directly; use <unistd.h> instead."
      21             : #endif
      22             : 
      23             : extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
      24             :                            size_t __buflen)
      25             :   __wur __attr_access ((__write_only__, 2, 3));
      26             : extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
      27             :                                           size_t __nbytes), read)
      28             :   __wur __attr_access ((__write_only__, 2, 3));
      29             : extern ssize_t __REDIRECT (__read_chk_warn,
      30             :                            (int __fd, void *__buf, size_t __nbytes,
      31             :                             size_t __buflen), __read_chk)
      32             :      __wur __warnattr ("read called with bigger length than size of "
      33             :                        "the destination buffer");
      34             : 
      35             : __fortify_function __wur ssize_t
      36    30408449 : read (int __fd, void *__buf, size_t __nbytes)
      37             : {
      38    15154411 :   return __glibc_fortify (read, __nbytes, sizeof (char),
      39             :                           __glibc_objsize0 (__buf),
      40             :                           __fd, __buf, __nbytes);
      41             : }
      42             : 
      43             : #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
      44             : extern ssize_t __pread_chk (int __fd, void *__buf, size_t __nbytes,
      45             :                             __off_t __offset, size_t __bufsize)
      46             :   __wur __attr_access ((__write_only__, 2, 3));
      47             : extern ssize_t __pread64_chk (int __fd, void *__buf, size_t __nbytes,
      48             :                               __off64_t __offset, size_t __bufsize)
      49             :   __wur __attr_access ((__write_only__, 2, 3));
      50             : extern ssize_t __REDIRECT (__pread_alias,
      51             :                            (int __fd, void *__buf, size_t __nbytes,
      52             :                             __off_t __offset), pread)
      53             :   __wur __attr_access ((__write_only__, 2, 3));
      54             : extern ssize_t __REDIRECT (__pread64_alias,
      55             :                            (int __fd, void *__buf, size_t __nbytes,
      56             :                             __off64_t __offset), pread64)
      57             :   __wur __attr_access ((__write_only__, 2, 3));
      58             : extern ssize_t __REDIRECT (__pread_chk_warn,
      59             :                            (int __fd, void *__buf, size_t __nbytes,
      60             :                             __off_t __offset, size_t __bufsize), __pread_chk)
      61             :      __wur __warnattr ("pread called with bigger length than size of "
      62             :                        "the destination buffer");
      63             : extern ssize_t __REDIRECT (__pread64_chk_warn,
      64             :                            (int __fd, void *__buf, size_t __nbytes,
      65             :                             __off64_t __offset, size_t __bufsize),
      66             :                             __pread64_chk)
      67             :      __wur __warnattr ("pread64 called with bigger length than size of "
      68             :                        "the destination buffer");
      69             : 
      70             : # ifndef __USE_FILE_OFFSET64
      71             : __fortify_function __wur ssize_t
      72       17705 : pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
      73             : {
      74       17705 :   return __glibc_fortify (pread, __nbytes, sizeof (char),
      75             :                           __glibc_objsize0 (__buf),
      76             :                           __fd, __buf, __nbytes, __offset);
      77             : }
      78             : # else
      79             : __fortify_function __wur ssize_t
      80             : pread (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
      81             : {
      82             :   return __glibc_fortify (pread64, __nbytes, sizeof (char),
      83             :                           __glibc_objsize0 (__buf),
      84             :                           __fd, __buf, __nbytes, __offset);
      85             : }
      86             : # endif
      87             : 
      88             : # ifdef __USE_LARGEFILE64
      89             : __fortify_function __wur ssize_t
      90             : pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
      91             : {
      92             :   return __glibc_fortify (pread64, __nbytes, sizeof (char),
      93             :                           __glibc_objsize0 (__buf),
      94             :                           __fd, __buf, __nbytes, __offset);
      95             : }
      96             : # endif
      97             : #endif
      98             : 
      99             : #if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
     100             : extern ssize_t __readlink_chk (const char *__restrict __path,
     101             :                                char *__restrict __buf, size_t __len,
     102             :                                size_t __buflen)
     103             :      __THROW __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
     104             : extern ssize_t __REDIRECT_NTH (__readlink_alias,
     105             :                                (const char *__restrict __path,
     106             :                                 char *__restrict __buf, size_t __len), readlink)
     107             :      __nonnull ((1, 2)) __wur __attr_access ((__write_only__, 2, 3));
     108             : extern ssize_t __REDIRECT_NTH (__readlink_chk_warn,
     109             :                                (const char *__restrict __path,
     110             :                                 char *__restrict __buf, size_t __len,
     111             :                                 size_t __buflen), __readlink_chk)
     112             :      __nonnull ((1, 2)) __wur __warnattr ("readlink called with bigger length "
     113             :                                           "than size of destination buffer");
     114             : 
     115             : __fortify_function __nonnull ((1, 2)) __wur ssize_t
     116             : __NTH (readlink (const char *__restrict __path, char *__restrict __buf,
     117             :                  size_t __len))
     118             : {
     119             :   return __glibc_fortify (readlink, __len, sizeof (char),
     120             :                           __glibc_objsize (__buf),
     121             :                           __path, __buf, __len);
     122             : }
     123             : #endif
     124             : 
     125             : #ifdef __USE_ATFILE
     126             : extern ssize_t __readlinkat_chk (int __fd, const char *__restrict __path,
     127             :                                  char *__restrict __buf, size_t __len,
     128             :                                  size_t __buflen)
     129             :      __THROW __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
     130             : extern ssize_t __REDIRECT_NTH (__readlinkat_alias,
     131             :                                (int __fd, const char *__restrict __path,
     132             :                                 char *__restrict __buf, size_t __len),
     133             :                                readlinkat)
     134             :      __nonnull ((2, 3)) __wur __attr_access ((__write_only__, 3, 4));
     135             : extern ssize_t __REDIRECT_NTH (__readlinkat_chk_warn,
     136             :                                (int __fd, const char *__restrict __path,
     137             :                                 char *__restrict __buf, size_t __len,
     138             :                                 size_t __buflen), __readlinkat_chk)
     139             :      __nonnull ((2, 3)) __wur __warnattr ("readlinkat called with bigger "
     140             :                                           "length than size of destination "
     141             :                                           "buffer");
     142             : 
     143             : __fortify_function __nonnull ((2, 3)) __wur ssize_t
     144           0 : __NTH (readlinkat (int __fd, const char *__restrict __path,
     145             :                    char *__restrict __buf, size_t __len))
     146             : {
     147           0 :   return __glibc_fortify (readlinkat, __len, sizeof (char),
     148             :                           __glibc_objsize (__buf),
     149             :                           __fd, __path, __buf, __len);
     150             : }
     151             : #endif
     152             : 
     153             : extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
     154             :      __THROW __wur;
     155             : extern char *__REDIRECT_NTH (__getcwd_alias,
     156             :                              (char *__buf, size_t __size), getcwd) __wur;
     157             : extern char *__REDIRECT_NTH (__getcwd_chk_warn,
     158             :                              (char *__buf, size_t __size, size_t __buflen),
     159             :                              __getcwd_chk)
     160             :      __wur __warnattr ("getcwd caller with bigger length than size of "
     161             :                        "destination buffer");
     162             : 
     163             : __fortify_function __wur char *
     164        1538 : __NTH (getcwd (char *__buf, size_t __size))
     165             : {
     166        1538 :   return __glibc_fortify (getcwd, __size, sizeof (char),
     167             :                           __glibc_objsize (__buf),
     168             :                           __buf, __size);
     169             : }
     170             : 
     171             : #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
     172             : extern char *__getwd_chk (char *__buf, size_t buflen)
     173             :      __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
     174             : extern char *__REDIRECT_NTH (__getwd_warn, (char *__buf), getwd)
     175             :      __nonnull ((1)) __wur __warnattr ("please use getcwd instead, as getwd "
     176             :                                        "doesn't specify buffer size");
     177             : 
     178             : __fortify_function __nonnull ((1)) __attribute_deprecated__ __wur char *
     179             : __NTH (getwd (char *__buf))
     180             : {
     181             :   if (__glibc_objsize (__buf) != (size_t) -1)
     182             :     return __getwd_chk (__buf, __glibc_objsize (__buf));
     183             :   return __getwd_warn (__buf);
     184             : }
     185             : #endif
     186             : 
     187             : extern size_t __confstr_chk (int __name, char *__buf, size_t __len,
     188             :                              size_t __buflen) __THROW
     189             :   __attr_access ((__write_only__, 2, 3));
     190             : extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf,
     191             :                                                 size_t __len), confstr)
     192             :    __attr_access ((__write_only__, 2, 3));
     193             : extern size_t __REDIRECT_NTH (__confstr_chk_warn,
     194             :                               (int __name, char *__buf, size_t __len,
     195             :                                size_t __buflen), __confstr_chk)
     196             :      __warnattr ("confstr called with bigger length than size of destination "
     197             :                  "buffer");
     198             : 
     199             : __fortify_function size_t
     200             : __NTH (confstr (int __name, char *__buf, size_t __len))
     201             : {
     202             :   return __glibc_fortify (confstr, __len, sizeof (char),
     203             :                           __glibc_objsize (__buf),
     204             :                           __name, __buf, __len);
     205             : }
     206             : 
     207             : 
     208             : extern int __getgroups_chk (int __size, __gid_t __list[], size_t __listlen)
     209             :   __THROW __wur __attr_access ((__write_only__, 2, 1));
     210             : extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]),
     211             :                            getgroups) __wur __attr_access ((__write_only__, 2, 1));
     212             : extern int __REDIRECT_NTH (__getgroups_chk_warn,
     213             :                            (int __size, __gid_t __list[], size_t __listlen),
     214             :                            __getgroups_chk)
     215             :      __wur __warnattr ("getgroups called with bigger group count than what "
     216             :                        "can fit into destination buffer");
     217             : 
     218             : __fortify_function int
     219        7608 : __NTH (getgroups (int __size, __gid_t __list[]))
     220             : {
     221        7608 :   return __glibc_fortify (getgroups, __size, sizeof (__gid_t),
     222             :                           __glibc_objsize (__list),
     223             :                           __size, __list);
     224             : }
     225             : 
     226             : 
     227             : extern int __ttyname_r_chk (int __fd, char *__buf, size_t __buflen,
     228             :                             size_t __nreal) __THROW __nonnull ((2))
     229             :    __attr_access ((__write_only__, 2, 3));
     230             : extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf,
     231             :                                                size_t __buflen), ttyname_r)
     232             :      __nonnull ((2));
     233             : extern int __REDIRECT_NTH (__ttyname_r_chk_warn,
     234             :                            (int __fd, char *__buf, size_t __buflen,
     235             :                             size_t __nreal), __ttyname_r_chk)
     236             :      __nonnull ((2)) __warnattr ("ttyname_r called with bigger buflen than "
     237             :                                  "size of destination buffer");
     238             : 
     239             : __fortify_function int
     240             : __NTH (ttyname_r (int __fd, char *__buf, size_t __buflen))
     241             : {
     242             :   return __glibc_fortify (ttyname_r, __buflen, sizeof (char),
     243             :                           __glibc_objsize (__buf),
     244             :                           __fd, __buf, __buflen);
     245             : }
     246             : 
     247             : 
     248             : #ifdef __USE_POSIX199506
     249             : extern int __getlogin_r_chk (char *__buf, size_t __buflen, size_t __nreal)
     250             :      __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
     251             : extern int __REDIRECT (__getlogin_r_alias, (char *__buf, size_t __buflen),
     252             :                        getlogin_r) __nonnull ((1));
     253             : extern int __REDIRECT (__getlogin_r_chk_warn,
     254             :                        (char *__buf, size_t __buflen, size_t __nreal),
     255             :                        __getlogin_r_chk)
     256             :      __nonnull ((1)) __warnattr ("getlogin_r called with bigger buflen than "
     257             :                                  "size of destination buffer");
     258             : 
     259             : __fortify_function int
     260             : getlogin_r (char *__buf, size_t __buflen)
     261             : {
     262             :   return __glibc_fortify (getlogin_r, __buflen, sizeof (char),
     263             :                           __glibc_objsize (__buf),
     264             :                           __buf, __buflen);
     265             : }
     266             : #endif
     267             : 
     268             : 
     269             : #if defined __USE_MISC || defined __USE_UNIX98
     270             : extern int __gethostname_chk (char *__buf, size_t __buflen, size_t __nreal)
     271             :      __THROW __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
     272             : extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen),
     273             :                            gethostname)
     274             :   __nonnull ((1)) __attr_access ((__write_only__, 1, 2));
     275             : extern int __REDIRECT_NTH (__gethostname_chk_warn,
     276             :                            (char *__buf, size_t __buflen, size_t __nreal),
     277             :                            __gethostname_chk)
     278             :      __nonnull ((1)) __warnattr ("gethostname called with bigger buflen than "
     279             :                                  "size of destination buffer");
     280             : 
     281             : __fortify_function int
     282        3304 : __NTH (gethostname (char *__buf, size_t __buflen))
     283             : {
     284        1421 :   return __glibc_fortify (gethostname, __buflen, sizeof (char),
     285             :                           __glibc_objsize (__buf),
     286             :                           __buf, __buflen);
     287             : }
     288             : #endif
     289             : 
     290             : 
     291             : #if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_UNIX98)
     292             : extern int __getdomainname_chk (char *__buf, size_t __buflen, size_t __nreal)
     293             :      __THROW __nonnull ((1)) __wur __attr_access ((__write_only__, 1, 2));
     294             : extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf,
     295             :                                                    size_t __buflen),
     296             :                            getdomainname) __nonnull ((1))
     297             :   __wur __attr_access ((__write_only__, 1, 2));
     298             : extern int __REDIRECT_NTH (__getdomainname_chk_warn,
     299             :                            (char *__buf, size_t __buflen, size_t __nreal),
     300             :                            __getdomainname_chk)
     301             :      __nonnull ((1)) __wur __warnattr ("getdomainname called with bigger "
     302             :                                        "buflen than size of destination "
     303             :                                        "buffer");
     304             : 
     305             : __fortify_function int
     306           0 : __NTH (getdomainname (char *__buf, size_t __buflen))
     307             : {
     308           0 :   return __glibc_fortify (getdomainname, __buflen, sizeof (char),
     309             :                           __glibc_objsize (__buf),
     310             :                           __buf, __buflen);
     311             : }
     312             : #endif

Generated by: LCOV version 1.14