tags 591133 + patch
thanks

Hi,

ncc calls lib/bcc-cpp, lib/bcc-cc1 and lib/copt, and they generate codes.
I found that lib/copt generated illegal one.

/tmp/linux86-0.16.17/lib/bcc-cpp __ldivmod.c -o xxx.0 -D__ELKS__  
-D__unix__-D__LIBC__ -D__HAS_NO_FLOATS__ -D__BCC_VERSION__=0x001011L -O 
-I/tmp/linux86-0.16.17/include -0
/tmp/linux86-0.16.17/lib/bcc-cc1 xxx.0 -o xxx.1 -O -0
/tmp/linux86-0.16.17/lib/copt xxx.1 -o xxx.2 -c! -d/tmp/linux86-0.16.17/lib 
rules.start rules.86

In xxx.1,

        .text
        .even

But lib/copt breaks it.

In xxx.2,

.txxt
.evvn

In linux86-0.16.17/copt/copt.c, readline breaks.

----------------------------------------------------------------------
static char *readline(FILE *fp)
{
  static char buf[MAXLINE];
  char *cp;

  /* Read line from input file */
  if (fgets(buf, MAXLINE-1, fp) == NULL)
        return(NULL);
  buf[MAXLINE-1] = '\0';

  /* Delete trailing newline */
  if ((cp = strchr(buf, '\n')) != NULL)
        *cp = '\0';

  /* Delete leading white spaces */
  for (cp = buf; *cp && isspace(*cp); cp++) ;
  if (cp != buf && *cp)
        strcpy(buf, cp); <<<<< ----- break

  return(buf);
}
----------------------------------------------------------------------

I replace strcpy by memmove.  patch attached.
It is inspired by 
http://cboard.cprogramming.com/c-programming/113133-remove-white-space.html .
-- 
Regards,
        dai

GPG Fingerprint = 0B29 D88E 42E6 B765 B8D8 EA50 7839 619D D439 668E
--- linux86-0.16.17/copt/copt.c.orig	2003-10-08 04:46:35.000000000 +0900
+++ linux86-0.16.17/copt/copt.c	2010-10-12 12:30:25.000000000 +0900
@@ -174,7 +174,7 @@ static char *readline(FILE *fp)
   /* Delete leading white spaces */
   for (cp = buf; *cp && isspace(*cp); cp++) ;
   if (cp != buf && *cp)
-	strcpy(buf, cp);
+	memmove(buf, cp, strlen(cp) + 1);
 
   return(buf);
 }

Attachment: signature.asc
Description: Digital signature

Reply via email to