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

Bug#193904: glibc: [patch] Re: locales.alias even lines are not considered



Followup-For: Bug #193904
Package: glibc
Version: N/A; reported 2003-05-20
Tags: patch

Hi all,

With the help of Bill, I've located the bug in intl/localealias.c: the
code that discards the end of an alias line when it doesn't fit in the
buffer should not be executed when the line fits in the buffer,
because it may discards one whole useful line.

I include a patch in a format suitable for debian/patches.

Regards,

Laurent.

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux kolvir 2.4.20-netfilter #19 Wed Feb 19 23:53:18 CET 2003 i686
Locale: LANG=C, LC_CTYPE=fr_FR@euro

-- 
So pardon me while I burn, and rise above the flame
#! /bin/sh -e

# All lines beginning with `# DP:' are a description of the patch.
# DP: Description: "Skip even line" fix in localealias.c
# DP: Author: Laurent Fousse <laurent@komite.net>
# DP: Upstream status: Not submitted
# DP: Status Details:
# DP: Date: May 20th, 2003

if [ $# -ne 2 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch) patch -d "$2" -f --no-backup-if-mismatch -p1 < $0;;
    -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p1 < $0;;
    *)
	echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
	exit 1
esac
exit 0

# append the patch here and adjust the -p? flag in the patch calls.
diff -u glibc-2.3.1/intl/localealias.c /home/laurent/libc/intl/localealias.c
--- glibc-2.3.1/intl/localealias.c	Tue May 20 10:40:41 2003
+++ /home/laurent/libc/intl/localealias.c	Tue May 20 10:43:06 2003
@@ -243,6 +243,7 @@
       char *alias;
       char *value;
       char *cp;
+      int whole_line_fits = 0;
 
       if (FGETS (buf, sizeof buf, fp) == NULL)
 	/* EOF reached.  */
@@ -283,6 +284,7 @@
 		     the terminating '\n' which do not overwrite here.  */
 		  *cp++ = '\0';
 		  *cp = '\n';
+		  whole_line_fits = 1;
 		}
 	      else if (cp[0] != '\0')
 		*cp++ = '\0';
@@ -334,11 +336,15 @@
 
       /* Possibly not the whole line fits into the buffer.  Ignore
 	 the rest of the line.  */
-      while (strchr (buf, '\n') == NULL)
-	if (FGETS (buf, sizeof buf, fp) == NULL)
-	  /* Make sure the inner loop will be left.  The outer loop
-	     will exit at the `feof' test.  */
-	  break;
+      if (whole_line_fits == 0)
+	{
+	  while (strchr (buf, '\n') == NULL)
+	    if (FGETS (buf, sizeof buf, fp) == NULL)
+	      /* Make sure the inner loop will be left.  The outer loop
+		 will exit at the `feof' test.  */
+	      break;
+	}
+      whole_line_fits = 0;
     }
 
   /* Should we test for ferror()?  I think we have to silently ignore

Attachment: pgpwiMwa2mPuF.pgp
Description: PGP signature


Reply to: