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

Re: Line length limit




The bug is in push, not popper. Please don't send mail to both
-discuss and -bugs.

/Johan

--- push.c	2003/04/04 02:10:17	1.47
+++ push.c	2004/06/17 14:03:35	1.48
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997-2001, 2003 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997-2004 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden). 
  * All rights reserved. 
  *
@@ -32,7 +32,7 @@
  */
 
 #include "push_locl.h"
-RCSID("$Id: push.c,v 1.47 2003/04/04 02:10:17 assar Exp $");
+RCSID("$Id: push.c,v 1.48 2004/06/17 14:03:35 joda Exp $");
 
 #ifdef KRB4
 static int use_v4 = -1;
@@ -214,9 +214,10 @@
     int ret;
     char out_buf[PUSH_BUFSIZ];
     int out_len = 0;
-    char in_buf[PUSH_BUFSIZ + 1];	/* sentinel */
+    char *in_buf;
+    size_t in_buf_size;
     size_t in_len = 0;
-    char *in_ptr = in_buf;
+    char *in_ptr;
     pop_state state = INIT;
     unsigned count, bytes;
     unsigned asked_for = 0, retrieved = 0, asked_deleted = 0, deleted = 0;
@@ -231,6 +232,10 @@
     int i;
     char *tmp = NULL;
 
+    in_buf = emalloc(PUSH_BUFSIZ + 1);
+    in_ptr = in_buf;
+    in_buf_size = PUSH_BUFSIZ;
+
     if (do_from) {
 	char *tmp2;
 
@@ -309,8 +314,15 @@
 	    char *beg, *p;
 	    size_t rem;
 	    int blank_line = 0;
+	    
+	    if(in_len >= in_buf_size) {
+		char *tmp = erealloc(in_buf, in_buf_size + PUSH_BUFSIZ + 1);
+		in_ptr = tmp + (in_ptr - in_buf);
+		in_buf = tmp;
+		in_buf_size += PUSH_BUFSIZ;
+	    }
 	    
-	    ret = read (s, in_ptr, sizeof(in_buf) - in_len - 1);
+	    ret = read (s, in_ptr, in_buf_size - in_len);
 	    if (ret < 0)
 		err (1, "read");
 	    else if (ret == 0)