Back to index

glibc  2.9
Functions
strcat_chk.c File Reference
#include <string.h>
#include <memcopy.h>

Go to the source code of this file.

Functions

char * __strcat_chk (char *dest, const char *src, size_t destlen)

Function Documentation

char* __strcat_chk ( char *  dest,
const char *  src,
size_t  destlen 
)

Definition at line 25 of file strcat_chk.c.

{
  char *s1 = dest;
  const char *s2 = src;
  reg_char c;

  /* Find the end of the string.  */
  do
    {
      if (__builtin_expect (destlen-- == 0, 0))
       __chk_fail ();
      c = *s1++;
    }
  while (c != '\0');

  /* Make S1 point before the next character, so we can increment
     it while memory is read (wins on pipelined cpus).  */
  ++destlen;
  s1 -= 2;

  do
    {
      if (__builtin_expect (destlen-- == 0, 0))
       __chk_fail ();
      c = *s2++;
      *++s1 = c;
    }
  while (c != '\0');

  return dest;
}

Here is the call graph for this function: