diff -Naur busybox.orig/printutils/lpd.c busybox/printutils/lpd.c
--- busybox.orig/printutils/lpd.c	2008-03-24 08:45:22 +0000
+++ busybox/printutils/lpd.c	2008-03-24 21:46:42 +0000
@@ -59,12 +59,14 @@
  *
  * Thus, a typical helper can be something like this:
  * #!/bin/sh
- * cat "$l" >/dev/lp0
- * mv -f "$l" save/
+ * cat "$DATAFILE" >/dev/lp0
+ * mv -f "$DATAFILE" save/
  */
 
 #include "libbb.h"
 
+#define ENABLE_FEATURE_LPD_PARANOIA 0	// are we Dr. Bernstein?
+
 // strip argument of bad chars
 static char *sane(char *str)
 {
@@ -85,8 +87,11 @@
 static void exec_helper(char **filenames, char **argv)
 {
 	char *p, *q;
+#if ENABLE_FEATURE_LPD_PARANOIA
 	char var[2];
 
+	var[1] = '\0';
+#endif
 	// read and delete ctrlfile
 	q = xmalloc_open_read_close(filenames[0], NULL);
 	unlink(filenames[0]);
@@ -94,14 +99,22 @@
 	xsetenv("DATAFILE", filenames[1]);
 	// parse control file by "\n"
 	while ((p = strchr(q, '\n')) != NULL
+#if ENABLE_FEATURE_LPD_PARANOIA
 	 && isalpha(*q)
+#endif
 	) {
 		*p++ = '\0';
 		// here q is a line of <SYM><VALUE>
 		// let us set environment string <SYM>=<VALUE>
-		var[0] = *q++;
-		var[1] = '\0';
-		xsetenv(var, q);
+		// N.B. DATAFILE set -> l (el) should be cleared
+		if (*q != 'l') {
+#if ENABLE_FEATURE_LPD_PARANOIA
+			var[0] = *q++;
+			xsetenv(var, q);
+#else
+			putenv(xasprintf("%c=%s", *q, q+1));
+#endif
+		}
 		// next line, plz!
 		q = p;
 	}
@@ -110,7 +123,7 @@
 	// (no daemonization is done)
 	bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO | DAEMON_ONLY_SANITIZE, NULL);
 	BB_EXECVP(*argv, argv);
-	exit(0);
+	exit(127); // it IS error if helper cannot be executed!
 }
 
 static char *xmalloc_read_stdin(void)
@@ -124,7 +137,6 @@
 int lpd_main(int argc ATTRIBUTE_UNUSED, char *argv[])
 {
 	int spooling = spooling; // for compiler
-	int seen;
 	char *s, *queue;
 	char *filenames[2];
 
@@ -135,8 +147,8 @@
 	// error messages of xfuncs will be sent over network
 	xdup2(STDOUT_FILENO, STDERR_FILENO);
 
-	filenames[0] = NULL; // ctrlfile name
-	filenames[1] = NULL; // datafile name
+	// nullify ctrl/data filenames
+	memset(filenames, 0, sizeof(filenames));
 
 	// read command
 	s = queue = xmalloc_read_stdin();
@@ -157,8 +169,8 @@
 
 	// queue is a directory -> chdir to it and enter spooling mode
 	spooling = chdir(queue) + 1; // 0: cannot chdir, 1: done
-	seen = 0;
 	// we don't free(queue), we might need it later
+	// N.B. he who wanna free queue should free(queue-1)!
 
 	while (1) {
 		char *fname;
@@ -187,11 +199,10 @@
 		// we understand only "control file" or "data file" cmds
 		if (2 != s[0] && 3 != s[0])
 			goto unsupported_cmd;
-		if (seen & (s[0] - 1)) {
+		if (ENABLE_FEATURE_LPD_PARANOIA && spooling & 1 << (s[0] - 1)) {
 			printf("Duplicated subcommand\n");
 			goto err_exit;
 		}
-		seen &= (s[0] - 1); // bit 1: ctrlfile; bit 2: datafile
 		// get filename
 		*strchrnul(s, '\n') = '\0';
 		fname = strchr(s, ' ');
@@ -211,7 +222,8 @@
 			printf("Bad length\n");
 			goto err_exit;
 		}
-		if (2 == s[0] && expected_len > 16 * 1024) {
+		// N.B. RFC says nothing! Why should we be "plus royal que le roi meme"?
+		if (ENABLE_FEATURE_LPD_PARANOIA && 2 == s[0] && expected_len > 16 * 1024) {
 			// SECURITY:
 			// ctrlfile can't be big (we want to read it back later!)
 			printf("File is too big\n");
@@ -242,6 +254,16 @@
 				expected_len, real_len);
 			goto err_exit;
 		}
+
+		if (spooling) {
+			// chmod completely downloaded file as "readable+writable"
+			fchmod(fd, 0600);
+			// accumulate dump state
+			// N.B. after all files are dumped spooling should be 1+2+4==7
+			// N.B. be careful! do not change *s before this line :)
+			spooling |= 1<<(s[0] - 1); // bit 1: ctrlfile; bit 2: datafile
+		}
+
 		// get ACK and see whether it is NUL (ok)
 		if (safe_read(STDIN_FILENO, s, 1) != 1 || s[0] != 0) {
 			// don't send error msg to peer - it obviously
@@ -250,18 +272,11 @@
 			goto err_exit;
 		}
 
-		if (spooling) {
-			// chmod completely downloaded file as "readable+writable"
-			fchmod(fd, 0600);
-			// accumulate dump state
-			// N.B. after all files are dumped spooling should be 1+2+3==6
-			spooling += s[0];
-		}
 		free(s);
 		close(fd); // NB: can do close(-1). Who cares?
 
 		// spawn spool helper and exit if all files are dumped
-		if (6 == spooling && *argv) {
+		if (7 == spooling && *argv) {
 			// signal OK
 			safe_write(STDOUT_FILENO, "", 1);
 			// does not return (exits 0)
@@ -272,10 +287,10 @@
  err_exit:
 	// don't keep corrupted files
 	if (spooling) {
-		if (filenames[0])
-			unlink(filenames[0]);
-		if (filenames[1])
-			unlink(filenames[1]);
+#define i spooling
+		for (i = 2; --i >= 0; )
+			if (filenames[i])
+				unlink(filenames[i]);
 	}
 	return EXIT_FAILURE;
 }
