home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / gnu / gcc / bug / 3123 < prev    next >
Encoding:
Text File  |  1993-01-06  |  2.9 KB  |  105 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!twinsun.COM!eggert
  3. From: eggert@twinsun.COM (Paul Eggert)
  4. Subject: more problems with signed char index array violations in GCC 2.3.3 cpp
  5. Message-ID: <9301060249.AA11652@farside.twinsun.com>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Wed, 6 Jan 1993 02:49:13 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 92
  12.  
  13. I looked for more array bound violations in cpp (GCC 2.3.3) and found four
  14. places in cccp.c where (on a machine where char is signed) a negative value
  15. might be used as a subscript, leading to possibly wrong answers and/or core
  16. dumps.  Here is a patch.
  17.  
  18.  
  19. Wed Jan  6 02:35:23 1993  Paul Eggert  (eggert@twinsun.com)
  20.  
  21.     * cccp.c (check_preconditions, do_error, do_warning, do_xifdef):
  22.     Don't use signed chars to index into arrays; they might be negative.
  23.  
  24. ===================================================================
  25. RCS file: RCS/cccp.c,v
  26. retrieving revision 2.3
  27. diff -c -r2.3 cccp.c
  28. *** cccp.c    1992/12/16 04:25:36    2.3
  29. --- cccp.c    1993/01/06 02:35:23
  30. ***************
  31. *** 4383,4392 ****
  32.         int len;
  33.         
  34.         prec += 5;
  35. !       while (is_hor_space[*prec])
  36.       prec++;
  37.         name = prec;
  38. !       while (is_idchar[*prec])
  39.       prec++;
  40.         len = prec - name;
  41.         
  42. --- 4383,4392 ----
  43.         int len;
  44.         
  45.         prec += 5;
  46. !       while (is_hor_space[(U_CHAR) *prec])
  47.       prec++;
  48.         name = prec;
  49. !       while (is_idchar[(U_CHAR) *prec])
  50.       prec++;
  51.         len = prec - name;
  52.         
  53. ***************
  54. *** 5827,5833 ****
  55.        struct directive *keyword;
  56.   {
  57.     int length = limit - buf;
  58. !   char *copy = (char *) xmalloc (length + 1);
  59.     bcopy (buf, copy, length);
  60.     copy[length] = 0;
  61.     SKIP_WHITE_SPACE (copy);
  62. --- 5827,5833 ----
  63.        struct directive *keyword;
  64.   {
  65.     int length = limit - buf;
  66. !   U_CHAR *copy = (U_CHAR *) xmalloc (length + 1);
  67.     bcopy (buf, copy, length);
  68.     copy[length] = 0;
  69.     SKIP_WHITE_SPACE (copy);
  70. ***************
  71. *** 5850,5856 ****
  72.        struct directive *keyword;
  73.   {
  74.     int length = limit - buf;
  75. !   char *copy = (char *) xmalloc (length + 1);
  76.     bcopy (buf, copy, length);
  77.     copy[length] = 0;
  78.     SKIP_WHITE_SPACE (copy);
  79. --- 5850,5856 ----
  80.        struct directive *keyword;
  81.   {
  82.     int length = limit - buf;
  83. !   U_CHAR *copy = (U_CHAR *) xmalloc (length + 1);
  84.     bcopy (buf, copy, length);
  85.     copy[length] = 0;
  86.     SKIP_WHITE_SPACE (copy);
  87. ***************
  88. *** 6094,6100 ****
  89.     if (ip->fname != 0 && keyword->type == T_IFNDEF) {
  90.       U_CHAR *p = ip->buf;
  91.       while (p != directive_start) {
  92. !       char c = *p++;
  93.         if (is_space[c])
  94.       ;
  95.         else if (c == '/' && p != ip->bufp && *p == '*') {
  96. --- 6094,6100 ----
  97.     if (ip->fname != 0 && keyword->type == T_IFNDEF) {
  98.       U_CHAR *p = ip->buf;
  99.       while (p != directive_start) {
  100. !       U_CHAR c = *p++;
  101.         if (is_space[c])
  102.       ;
  103.         else if (c == '/' && p != ip->bufp && *p == '*') {
  104.  
  105.