Ticket #6329: makeinfo-strcpy-overlap.patch

File makeinfo-strcpy-overlap.patch, 899 bytes (added by Shisui, 14 years ago)
  • makeinfo.c

     
    11/* Makeinfo -- convert Texinfo source files into Info files.
    2    $Id: makeinfo.c,v 1.1 2004/10/28 18:14:10 zooey Exp $
     2   $Id$
    33
    44   Copyright (C) 1987, 92, 93, 94, 95, 96, 97, 98
    55   Free Software Foundation, Inc.
     
    16721672void
    16731673canon_white (string)
    16741674     char *string;
    1675 {
     1675{
     1676  char *temp;
    16761677  int len = strlen (string);
    16771678  int x;
    16781679
     
    16831684    {
    16841685      if (!cr_or_whitespace (string[x]))
    16851686        {
    1686           strcpy (string, string + x);
     1687          /* The destination may _not_ overlap ! -- strcpy (string, string + x); */
     1688          temp = malloc(len * sizeof(char) + 1);
     1689          strcpy(temp, string+x);
     1690          strcpy(string, temp);
     1691          free(temp);
    16871692          break;
    16881693        }
    16891694    }