wchar_t * __wmemset_chk (wchar_t *s, wchar_t c, size_t n, size_t dstlen) { if (__builtin_expect (dstlen < n, 0)) __chk_fail (); return wmemset (s, c, n); }
ssize_t __recv_chk (int fd, void *buf, size_t n, size_t buflen, int flags) { if (n > buflen) __chk_fail (); return __recv (fd, buf, n, flags); }
int __gethostname_chk (char *buf, size_t buflen, size_t nreal) { if (buflen > nreal) __chk_fail (); return __gethostname (buf, buflen); }
long int __fdelt_chk (long int d) { if (d < 0 || d >= FD_SETSIZE) __chk_fail (); return d / __NFDBITS; }
/* Copy no more than N characters of SRC to DEST, returning the address of the terminating '\0' in DEST, if any, or else DEST + N. */ char * __stpncpy_chk (char *dest, const char *src, size_t n, size_t destlen) { if (__builtin_expect (destlen < n, 0)) __chk_fail (); return __stpncpy (dest, src, n); }
size_t __confstr_chk (int name, char *buf, size_t len, size_t buflen) { if (__glibc_unlikely (buflen < len)) __chk_fail (); return confstr (name, buf, len); }
size_t __confstr_chk (int name, char *buf, size_t len, size_t buflen) { if (__builtin_expect (buflen < len, 0)) __chk_fail (); return confstr (name, buf, len); }
char * __strncpy_chk (char *s1, const char *s2, size_t n, size_t s1len) { if (__builtin_expect (s1len < n, 0)) __chk_fail (); return strncpy (s1, s2, n); }
ssize_t __pread64_chk (int fd, void *buf, size_t nbytes, off64_t offset, size_t buflen) { if (nbytes > buflen) __chk_fail (); return __libc_pread64 (fd, buf, nbytes, offset); }
int __ttyname_r_chk (int fd, char *buf, size_t buflen, size_t nreal) { if (buflen > nreal) __chk_fail (); return __ttyname_r (fd, buf, buflen); }
void * __memset_chk (void *dstpp, int c, size_t len, size_t dstlen) { if (__glibc_unlikely (dstlen < len)) __chk_fail (); return memset (dstpp, c, len); }
int __getlogin_r_chk (char *buf, size_t buflen, size_t nreal) { if (buflen > nreal) __chk_fail (); return getlogin_r (buf, buflen); }
char * __getwd_chk (char *buf, size_t buflen) { char *res = __getcwd (buf, buflen); if (res == NULL && errno == ERANGE) __chk_fail (); return res; }
wchar_t * __wmempcpy_chk (wchar_t *s1, const wchar_t *s2, size_t n, size_t ns1) { if (__glibc_unlikely (ns1 < n)) __chk_fail (); return (wchar_t *) __mempcpy ((char *) s1, (char *) s2, n * sizeof (wchar_t)); }
ssize_t __readlinkat_chk (int fd, const char *path, void *buf, size_t len, size_t buflen) { if (len > buflen) __chk_fail (); return readlinkat (fd, path, buf, len); }
int __vsnprintf_chk (char *s, size_t n, int flags __attribute__((unused)), size_t slen, const char *format, va_list arg) { if (n > slen) __chk_fail (); return vsnprintf (s, n, format, arg); }
int __ppoll_chk (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const __sigset_t *ss, __SIZE_TYPE__ fdslen) { if (fdslen / sizeof (*fds) < nfds) __chk_fail (); return ppoll (fds, nfds, timeout, ss); }
size_t __wcsnrtombs_chk (char *dst, const wchar_t **src, size_t nwc, size_t len, mbstate_t *ps, size_t dstlen) { if (__builtin_expect (dstlen < len, 0)) __chk_fail (); return __wcsnrtombs (dst, src, nwc, len, ps); }
/* Copy SRC to DEST, returning the address of the terminating '\0' in DEST. */ char * __stpcpy_chk (char *dest, const char *src, size_t destlen) { size_t len = strlen (src); if (len >= destlen) __chk_fail (); return memcpy (dest, src, len + 1) + len; }
char * __gets_chk (char *buf, size_t size) { size_t count; int ch; char *retval; if (size == 0) __chk_fail (); _IO_acquire_lock (stdin); ch = _IO_getc_unlocked (stdin); if (ch == EOF) { retval = NULL; goto unlock_return; } if (ch == '\n') count = 0; else { /* This is very tricky since a file descriptor may be in the non-blocking mode. The error flag doesn't mean much in this case. We return an error only when there is a new error. */ int old_error = stdin->_flags & _IO_ERR_SEEN; stdin->_flags &= ~_IO_ERR_SEEN; buf[0] = (char) ch; count = _IO_getline (stdin, buf + 1, size - 1, '\n', 0) + 1; if (stdin->_flags & _IO_ERR_SEEN) { retval = NULL; goto unlock_return; } else stdin->_flags |= old_error; } if (count >= size) __chk_fail (); buf[count] = 0; retval = buf; unlock_return: _IO_release_lock (stdin); return retval; }
int __wctomb_chk (char *s, wchar_t wchar, size_t buflen) { /* We do not have to implement the full wctomb semantics since we know that S cannot be NULL when we come here. */ if (buflen < MB_CUR_MAX) __chk_fail (); return __wcrtomb (s, wchar, &__wctomb_state); }
/* Copy SRC to DEST, returning the address of the terminating L'\0' in DEST. Check for overflows. */ wchar_t * __wcpcpy_chk (wchar_t *dest, const wchar_t *src, size_t destlen) { do if (destlen-- == 0) __chk_fail (); while ((*dest++ = *src++)); return dest - 1; }
/* Copy no more than N wide-characters of SRC to DEST. */ wchar_t * __wcpncpy_chk (wchar_t *dest, const wchar_t *src, size_t n, size_t destlen) { if (__builtin_expect (destlen < n, 0)) __chk_fail (); /* This function is not often enough used to justify not using a tail call. */ return __wcpncpy (dest, src, n); }
void __explicit_bzero_chk (void *dst, size_t len, size_t dstlen) { /* Inline __memset_chk to avoid a PLT reference to __memset_chk. */ if (__glibc_unlikely (dstlen < len)) __chk_fail (); memset (dst, '\0', len); /* Compiler barrier. */ asm volatile ("" ::: "memory"); }
char * __strncpy_chk (char *s1, const char *s2, __SIZE_TYPE__ n, __SIZE_TYPE__ size) { /* If size is -1, GCC should always optimize the call into strncpy. */ if (size == (__SIZE_TYPE__) -1) abort (); ++chk_calls; if (n > size) __chk_fail (); return strncpy (s1, s2, n); }
char * __strcat_chk (char *d, const char *s, __SIZE_TYPE__ size) { /* If size is -1, GCC should always optimize the call into strcat. */ if (size == (__SIZE_TYPE__) -1) abort (); ++chk_calls; if (strlen (d) + strlen (s) >= size) __chk_fail (); return strcat (d, s); }
void * __mempcpy_chk (void *dst, const void *src, __SIZE_TYPE__ n, __SIZE_TYPE__ size) { /* If size is -1, GCC should always optimize the call into mempcpy. */ if (size == (__SIZE_TYPE__) -1) abort (); ++chk_calls; if (n > size) __chk_fail (); return mempcpy (dst, src, n); }
ssize_t __readlink_chk (const char *path, void *buf, size_t len, size_t buflen) { if (len > buflen) __chk_fail (); #ifdef HAVE_INLINED_SYSCALLS return INLINE_SYSCALL (readlinkat, 4, AT_FDCWD, path, buf, len); #else return __readlink (path, buf, len); #endif }
size_t __mbstowcs_chk (wchar_t *dst, const char *src, size_t len, size_t dstlen) { if (__builtin_expect (dstlen < len, 0)) __chk_fail (); mbstate_t state; memset (&state, '\0', sizeof state); /* Return how many we wrote (or maybe an error). */ return __mbsrtowcs (dst, &src, len, &state); }
ssize_t __read_chk (int fd, void *buf, size_t nbytes, size_t buflen) { if (nbytes > buflen) __chk_fail (); #ifdef HAVE_INLINED_SYSCALLS return INLINE_SYSCALL (read, 3, fd, buf, nbytes); #else return __read (fd, buf, nbytes); #endif }