Re: [Sawfish] rep read-line limit

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


On Wednesday 14 March 2012 23:10:34 Timo Korvola wrote:
> Maybe like this.  Not extensively tested though, and may now run out
> of memory on very long lines.

Hm, looks like there will be an invalid memory access if EOF is 
encountered immediately (readlen = offset = 0). This should fix that.

	Timo
From 152ee22b4e2df0cace6f327d62f7af6cb6119211 Mon Sep 17 00:00:00 2001
From: Timo Korvola <tkorvola@xxxxxx>
Date: Fri, 23 Mar 2012 14:44:07 +0200
Subject: [PATCH] Avoid invalid memory access if readlen == 0.

---
 src/streams.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/streams.c b/src/streams.c
index 0711975..4e9d794 100644
--- a/src/streams.c
+++ b/src/streams.c
@@ -695,7 +695,7 @@ characters can be read, return nil.
                     break;
             }
         }
-        if (offbuf[readlen - 1] == '\n' || readlen < maxread)
+        if (readlen < maxread || offbuf[readlen - 1] == '\n')
         {
             int fulllen = offset + readlen;
             repv rval = fulllen ? rep_string_dupn (fullbuf, fulllen) : Qnil;
-- 
1.7.2.5



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/