[Date Prev][Date Next] [Chronological] [Thread] [Top]

Infinite loops in ucgendat.c (EOF test) (ITS#1917)

Full_Name: Richard Shaffer
Version: 2.1.2
OS: Linux (Red Hat 7)
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

During the "make" process, the command "./ucgendat $(srcdir)/UnicodeData.txt -x
$(srcdir)/CompositionExclusions.txt" is run (in libraries/liblunicode).  On my
system, a very vanilla version of RedHat 7, this program goes into an infinite
loop when the read_cdata function reaches the end of the UnicodeData.txt file. 
The reason is that the call to fscanf at line 807 of ucgendat.c returns 0 when
the end of the file is reached, instead of EOF.  I am using gcc version 2.96 as
the compiler, and glibc version 2.1.92.

To work around this problem, I used feof() to determine an end of file condition
instead of relying on the return value from fscanf.  Following is a copy of the
patch I used to work around the problem.  I've uploaded my config.log to

----------Start Patch----------
--- ucgendat.c  Fri Jun 28 10:53:12 2002
+++ ucgendat.c.orig     Fri Jun 28 10:52:56 2002
@@ -804,8 +804,7 @@
     char line[512], *s, *e;

     lineno = skip = 0;
-    while (!feof(in)) {
-        fscanf(in, "%[^\n]\n", line);
+    while (fscanf(in, "%[^\n]\n", line) != EOF) {

@@ -1163,8 +1162,7 @@

     (void) memset((char *) compexs, 0, sizeof(unsigned long) << 11);

-    while (!feof(in)) {
-        fscanf(in, "%[^\n]\n", line);
+    while (fscanf(in, "%[^\n]\n", line) != EOF) {
          * Skip blank lines and lines that start with a '#'.
-----------End Patch-----------