More on DSN woes

maf@tkrat.org maf@tkrat.org
Wed, 5 Nov 2003 04:43:30 -0800 (PST)


--397199618-1804289383-1068036210=:810
Content-Type: TEXT/PLAIN; CHARSET=us-ascii
Content-Disposition: INLINE

On 15 Oct, Chris Tubutis wrote:
> The contents of my index file are now:
> 3f8dfaa8.4575 1066269352 {unlink("/home/chris/.ratatosk/DSN/3f8dc72e.5e2") = -1 ENOENT (No^M such file or directory)} {{none tkrat@tkrat.org {}}}

Here is the clue to the problem. The problem is triggered by newlines
which are embedded in the subject. This also explains the garbage-line
you found in your index-file. The attached patch fixes this problem.

	/MaF

--397199618-1804289383-1068036210=:810
Content-Type: TEXT/PLAIN; NAME="diff.dsn"
Content-Disposition: ATTACHMENT; FILENAME="diff.dsn"

Index: lib/ratDSN.c
===================================================================
RCS file: /usr/site/share/cvsroot/ratatosk/lib/Attic/ratDSN.c,v
retrieving revision 1.41.2.1
diff -u -r1.41.2.1 ratDSN.c
--- lib/ratDSN.c	17 Feb 2003 16:52:12 -0000	1.41.2.1
+++ lib/ratDSN.c	5 Nov 2003 12:36:20 -0000
@@ -89,7 +89,7 @@
 RatDSNStartMessage(Tcl_Interp *interp, const char *id, const char *subject)
 {
     Tcl_DString *dsPtr = (Tcl_DString*)ckalloc(sizeof(Tcl_DString));
-    char buf[32], *header, *cPtr;
+    unsigned char buf[32], *header, *cPtr;
     time_t seconds;
 
     Tcl_DStringInit(dsPtr);
@@ -97,9 +97,11 @@
     seconds = time(NULL);
     sprintf(buf, "%d", (int)seconds);
     Tcl_DStringAppendElement(dsPtr, buf);
-    cPtr = header = RatDecodeHeader(interp, subject, 0);
-    while ((cPtr = strchr(cPtr, '\n'))) {
-	*cPtr++ = ' ';
+    header = RatDecodeHeader(interp, subject, 0);
+    for (cPtr = header; *cPtr; cPtr++) {
+	if (*cPtr < 32) {
+	    *cPtr = ' ';
+	}
     }
     Tcl_DStringAppendElement(dsPtr, header);
     Tcl_DStringStartSublist(dsPtr);
@@ -258,6 +260,13 @@
     Tcl_GetIntFromObj(interp, oPtr, &perm);
     dir = RatGetPathOption(interp, "dsn_directory");
     while (linePtr = Tcl_NewObj(), -1 != Tcl_GetsObj(channel, linePtr)) {
+	/* Join lines until we have a valid list */
+	while (0 != Tcl_ListObjLength(interp, linePtr, &i)
+	       && -1 != Tcl_GetsObj(channel, linePtr));
+	if (i != 4) {
+	    /* If the list does not have 4 elements it is invalid */
+	    continue;
+	}
 	if (RatDSNExpire(interp, linePtr)) {
 	    /*
 	     * This DSN has expired so we should remove all associated files

--397199618-1804289383-1068036210=:810--