Back to index

glibc  2.9
Functions
fread_chk.c File Reference
#include "libioP.h"
#include <stdio.h>

Go to the source code of this file.

Functions

size_t __fread_chk (void *__restrict ptr, size_t ptrlen, size_t size, size_t n, FILE *__restrict stream)

Function Documentation

size_t __fread_chk ( void *__restrict  ptr,
size_t  ptrlen,
size_t  size,
size_t  n,
FILE *__restrict  stream 
)

Definition at line 33 of file fread_chk.c.

{
  size_t bytes_requested = size * n;
  if (__builtin_expect ((n | size)
                     >= (((size_t) 1) << (8 * sizeof (size_t) / 2)), 0))
    {
      if (size != 0 && bytes_requested / size != n)
       __chk_fail ();
    }

  if (__builtin_expect (bytes_requested > ptrlen, 0))
    __chk_fail ();

  CHECK_FILE (stream, 0);
  if (bytes_requested == 0)
    return 0;

  size_t bytes_read;
  _IO_acquire_lock (stream);
  bytes_read = INTUSE(_IO_sgetn) (stream, (char *) ptr, bytes_requested);
  _IO_release_lock (stream);
  return bytes_requested == bytes_read ? n : bytes_read / size;
}

Here is the call graph for this function:

Here is the caller graph for this function: