Subject: [netatalk-admins] fixing papd - pre-patch 2

From: Andras Kadinger <[email-masked]>
Date: Fri, 04 Sep 1998 02:00:15 +0200

Ok, if the previous one wasn't too bad, the you might want to try this.
It should be applied over pre1.

This limits the line length papd will want to consider as one line to an
(arbitrary) 4096 bytes; no good mannered DSC-conforming document should
have lines longer than 255 bytes as per spec, so this hopefully won't
hurt much. Most importantly, it will keep papd from eating up all memory
in the machine (and in nearby computer stores). Also, since the line
length is limited, papd no longer will spend a lifetime in it's quest
for finding a line ending character in a - let's say - 10MB long 'line'
each time as it grows from zero to 10MB in 1K increments as could happen
before. Since our ATP/PAP stack is not asynchronous, I bet this will
help with people's timeout problems...

Andras

PS: I hand modified the patch so it might not apply cleanly, but since
it's a one-liner, applying by hand is fairly trivial. Mail me if you
want pre1 and pre2 rolled together.

diff -udr netatalk-1.4b2+asun2.1.0-original/etc/papd/file.c netatalk-1.4b2+asun2.1.0/etc/papd/file.c
--- netatalk-1.4b2+asun2.1.0-original/etc/papd/file.c	Tue May 20 19:35:42 1997
+++ netatalk-1.4b2+asun2.1.0/etc/papd/file.c	Fri Sep  4 01:34:25 1998
@@ -23,8 +23,8 @@
 
     /* get a line */
     for ( p = pf->pf_cur; p < pf->pf_end; p++ ) {
-	if ( *p == '\n' || *p == '\r' ) {
+	if ( *p == '\n' || *p == '\r' || ((*p - pf->pf_cur)>4096) ) {
 	    break;
 	}
     }