Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watcgl.UUCP Path: utzoo!watmath!watcgl!dmmartindale From: dmmartindale@watcgl.UUCP (Dave Martindale) Newsgroups: net.news.b Subject: inews puts \377 into control messages Message-ID: <617@watcgl.UUCP> Date: Sun, 2-Dec-84 14:10:42 EST Article-I.D.: watcgl.617 Posted: Sun Dec 2 14:10:42 1984 Date-Received: Tue, 4-Dec-84 06:16:56 EST Distribution: net Organization: U of Waterloo, Ontario Lines: 81 There is code in insert() in inews.c that tries to compensate for the now-infamous line-eater bug; if an article begins with a blank or tab an extra newline is added to the beginning of the body of the article. Unfortunately, this code doesn't check for the case of a zero-length article body - this is impossible for a normal article being posted, but is always the case for some control messages (i.e. cancel). So the code does a getc() which returns EOF into a char and later does a putc of it into the article body, which results in a \377 character in the article. Normally this wouldn't bother anyone, but if you then try to mail such an article body using the MMDF software, pmdf apparently dies a horrible death. Fixes to inews.c are as follows: *** /tmp/inews.c Sun Dec 2 13:46:43 1984 --- inews.c Sun Dec 2 13:50:10 1984 *************** *** 504,510 { register char *ptr; register FILE *tfp; ! char c; struct srec srec; /* struct for sys file lookup */ int is_invalid = FALSE; --- 504,510 ----- { register char *ptr; register FILE *tfp; ! register int c; struct srec srec; /* struct for sys file lookup */ int is_invalid = FALSE; *************** *** 529,535 /* Write article to temp file. */ tfp = xfopen(mktemp(ARTICLE), "w"); ! if ( (c=getc(infp)) == ' ' || c == '\t' ) { header.intnumlines++; sprintf(header.numlines,"%d",header.intnumlines); } --- 529,536 ----- /* Write article to temp file. */ tfp = xfopen(mktemp(ARTICLE), "w"); ! /* part of kludge to get around article truncation problem */ ! if ( (c=getc(infp)) != EOF && (c == ' ' || c == '\t') ) { header.intnumlines++; sprintf(header.numlines,"%d",header.intnumlines); } *************** *** 535,543 } lhwrite(&header, tfp); /* Kludge to get around article truncation problem */ ! if (c == ' ' || c == '\t' ) ! putc('\n', tfp); ! putc(c,tfp); while (fgets(bfr, BUFLEN, infp) != NULL) fputs(bfr, tfp); --- 536,546 ----- } lhwrite(&header, tfp); /* Kludge to get around article truncation problem */ ! if (c != EOF) { ! if (c == ' ' || c == '\t' ) ! putc('\n', tfp); ! putc(c,tfp); ! } while (fgets(bfr, BUFLEN, infp) != NULL) fputs(bfr, tfp); Even though the "while (fgets..." code could have been put inside the body of the "if (c != EOF)" if statement, I left it out since the kludge should one day be deleted, leaving just the while loop to copy the article body. Dave Martindale