about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-06-25 18:16:11 +0000
committerUlrich Drepper <drepper@redhat.com>2002-06-25 18:16:11 +0000
commitcf1557437b7047d1b0376fe2e8df36fb209cfd04 (patch)
treea24656c18525d78e8895113a5add679edcf68f7a
parent13cfe89932ea25be5d21201d9fde2838ef842f34 (diff)
downloadglibc-cf1557437b7047d1b0376fe2e8df36fb209cfd04.tar.gz
glibc-cf1557437b7047d1b0376fe2e8df36fb209cfd04.tar.xz
glibc-cf1557437b7047d1b0376fe2e8df36fb209cfd04.zip
(__argp_fmtstream_update): Avoid crash in handling of overly long words.
-rw-r--r--argp/argp-fmtstream.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 0223806e73..c3d3787d18 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -1,5 +1,5 @@
 /* Word-wrapping and line-truncating streams
-   Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -267,9 +267,10 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
 	     at the end of the buffer, and NEXTLINE is in fact empty (and so
 	     we need not be careful to maintain its contents).  */
 
-	  if (nextline == buf + len + 1
-	      ? fs->end - nl < fs->wmargin + 1
-	      : nextline - (nl + 1) < fs->wmargin)
+	  if ((nextline == buf + len + 1
+	       ? fs->end - nl < fs->wmargin + 1
+	       : nextline - (nl + 1) < fs->wmargin)
+	      && fs->p > nextline)
 	    {
 	      /* The margin needs more blanks than we removed.  */
 	      if (fs->end - fs->p > fs->wmargin + 1)