bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: htags will cause segmentation fault if source file does not end with


From: Shigio YAMAGUCHI
Subject: Re: htags will cause segmentation fault if source file does not end with newline
Date: Fri, 17 Dec 2010 23:19:08 +0900

Wes.

I believe I have fixed the bug.
Thank you for your sending the materials.

Shigio

> Attached is file from joomla - it fails as it is - it will pass if I add
> newline at the end of the file.

Index: htags/asm.l
===================================================================
RCS file: /sources/global/global/htags/asm.l,v
retrieving revision 1.20
diff -c -r1.20 asm.l
*** htags/asm.l 22 May 2010 11:35:43 -0000      1.20
--- htags/asm.l 17 Dec 2010 14:03:23 -0000
***************
*** 94,101 ****
                 * #include|   <aaa/bbb.h>|
                 *         ~~~~~~~~~~~~~~~~
                 */
!               while ((c = input()) && c != '\n' && isspace(c))
                        echoc(c);
                if (c == '\n') {
                        unput(c);
                } else if (c) {
--- 94,103 ----
                 * #include|   <aaa/bbb.h>|
                 *         ~~~~~~~~~~~~~~~~
                 */
!               while ((c = input()) && c != EOF && c != '\n' && isspace(c))
                        echoc(c);
+               if (c == EOF)
+                       c = '\n';
                if (c == '\n') {
                        unput(c);
                } else if (c) {
***************
*** 109,117 ****
                        put_char(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != '\n' && c != sep)
                                *p++ = c;
                        *p = '\0';
                        if (c == sep) {
                                struct data *inc;
                                const char *basename = locatestring(path, "/", 
MATCH_LAST);
--- 111,121 ----
                        put_char(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != EOF && c != '\n' && c != 
sep)
                                *p++ = c;
                        *p = '\0';
+                       if (c == EOF)
+                               c = '\n';
                        if (c == sep) {
                                struct data *inc;
                                const char *basename = locatestring(path, "/", 
MATCH_LAST);
Index: htags/c.l
===================================================================
RCS file: /sources/global/global/htags/c.l,v
retrieving revision 1.28
diff -c -r1.28 c.l
*** htags/c.l   22 May 2010 11:35:43 -0000      1.28
--- htags/c.l   17 Dec 2010 14:03:23 -0000
***************
*** 107,114 ****
                 * #include|   <aaa/bbb.h>|
                 *         ~~~~~~~~~~~~~~~~
                 */
!               while ((c = input()) && c != '\n' && isspace(c))
                        echoc(c);
                if (c == '\n') {
                        unput(c);
                } else if (c) {
--- 107,116 ----
                 * #include|   <aaa/bbb.h>|
                 *         ~~~~~~~~~~~~~~~~
                 */
!               while ((c = input()) && c != EOF && c != '\n' && isspace(c))
                        echoc(c);
+               if (c == EOF)
+                       c = '\n';
                if (c == '\n') {
                        unput(c);
                } else if (c) {
***************
*** 122,130 ****
                        put_char(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != '\n' && c != sep)
                                *p++ = c;
                        *p = '\0';
                        if (c == sep) {
                                struct data *inc;
                                const char *basename = locatestring(path, "/", 
MATCH_LAST);
--- 124,134 ----
                        put_char(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != EOF && c != '\n' && c != 
sep)
                                *p++ = c;
                        *p = '\0';
+                       if (c == EOF)
+                               c = '\n';
                        if (c == sep) {
                                struct data *inc;
                                const char *basename = locatestring(path, "/", 
MATCH_LAST);
Index: htags/cpp.l
===================================================================
RCS file: /sources/global/global/htags/cpp.l,v
retrieving revision 1.24
diff -c -r1.24 cpp.l
*** htags/cpp.l 22 May 2010 11:35:43 -0000      1.24
--- htags/cpp.l 17 Dec 2010 14:03:23 -0000
***************
*** 94,101 ****
                 * #include|   <aaa/bbb.h>|
                 *         ~~~~~~~~~~~~~~~~
                 */
!               while ((c = input()) && c != '\n' && isspace(c))
                        echoc(c);
                if (c == '\n') {
                        unput(c);
                } else if (c) {
--- 94,103 ----
                 * #include|   <aaa/bbb.h>|
                 *         ~~~~~~~~~~~~~~~~
                 */
!               while ((c = input()) && c != EOF && c != '\n' && isspace(c))
                        echoc(c);
+               if (c == EOF)
+                       c = '\n';
                if (c == '\n') {
                        unput(c);
                } else if (c) {
***************
*** 109,117 ****
                        put_char(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != sep && c != '\n')
                                *p++ = c;
                        *p = '\0';
                        if (c == sep) {
                                struct data *inc;
                                const char *basename = locatestring(path, "/", 
MATCH_LAST);
--- 111,121 ----
                        put_char(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != EOF && c != sep && c != 
'\n')
                                *p++ = c;
                        *p = '\0';
+                       if (c == EOF)
+                               c = '\n';
                        if (c == sep) {
                                struct data *inc;
                                const char *basename = locatestring(path, "/", 
MATCH_LAST);
Index: htags/java.l
===================================================================
RCS file: /sources/global/global/htags/java.l,v
retrieving revision 1.14
diff -c -r1.14 java.l
*** htags/java.l        21 May 2010 01:43:14 -0000      1.14
--- htags/java.l        17 Dec 2010 14:03:23 -0000
***************
*** 79,86 ****
                int c = 0;
  
                put_reserved_word(LEXTEXT);
!               while ((c = input()) && c != '\n' && c != ';')
                        echoc(c);
                if (c == '\n')
                        unput(c);
                else if (c)
--- 79,88 ----
                int c = 0;
  
                put_reserved_word(LEXTEXT);
!               while ((c = input()) && c != EOF && c != '\n' && c != ';')
                        echoc(c);
+               if (c == EOF)
+                       c = '\n';
                if (c == '\n')
                        unput(c);
                else if (c)
Index: htags/php.l
===================================================================
RCS file: /sources/global/global/htags/php.l,v
retrieving revision 1.24
diff -c -r1.24 php.l
*** htags/php.l 22 May 2010 11:35:43 -0000      1.24
--- htags/php.l 17 Dec 2010 14:03:23 -0000
***************
*** 127,150 ****
                 * include   'aaa/bbb.h';
                 *        ^
                 */
!               while ((c = input()) && c != '\n' && isspace(c))
                        echoc(c);
                if (c == '\n')
                        unput(c);
                else if (c) {
                        char path[MAXPATHLEN], *p = path;
                        int sep = 0;
  
!                       if (c == LEFT_BRACE)
                                c = input();
                        if (c == '"' || c == '\'')
                                sep = c;
                        echoc(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != '\n' && c != sep)
                                *p++ = c;
                        *p = '\0';
                        if (c == sep) {
                                char tmp[MAXPATHLEN];
                                char normalized_path[MAXPATHLEN];
--- 127,157 ----
                 * include   'aaa/bbb.h';
                 *        ^
                 */
!               while ((c = input()) && c != EOF && c != '\n' && isspace(c))
                        echoc(c);
+               if (c == EOF)
+                       c = '\n';
                if (c == '\n')
                        unput(c);
                else if (c) {
                        char path[MAXPATHLEN], *p = path;
                        int sep = 0;
  
!                       if (c == LEFT_BRACE) {
                                c = input();
+                               if (c == EOF)
+                                       c = '\n';
+                       }
                        if (c == '"' || c == '\'')
                                sep = c;
                        echoc(c);
  
                        /* pick up path name */
!                       while ((c = input()) && c != EOF && c != '\n' && c != 
sep)
                                *p++ = c;
                        *p = '\0';
+                       if (c == EOF)
+                               c = '\n';
                        if (c == sep) {
                                char tmp[MAXPATHLEN];
                                char normalized_path[MAXPATHLEN];
--
Shigio YAMAGUCHI <address@hidden>
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3



reply via email to

[Prev in Thread] Current Thread [Next in Thread]