Xref: utzoo news.software.b:2289 comp.sources.d:3748 Newsgroups: news.software.b,comp.sources.d Path: utzoo!utgpu!utstat!geoff From: geoff@utstat.uucp (Geoff Collyer) Subject: C News production release bugs Message-ID: <1989Jun13.034954.144@utstat.uucp> Organization: Statistics, U. of Toronto Date: Tue, 13 Jun 89 03:49:54 GMT Disclaimer: Henry and I do not subscribe to the patch-of-the-day club. We are even less happy about software whose patches precede it. However, the following bugs, all involving control messages, need fixing. We know of no other bugs in the production release. These fixes will appear in the comp.sources.unix distribution, to appear after Usenix. Sites making C news available for uucp, ftp, etc. are asked to update their C news distributions (often just cnews.Z). The old cnews.Z was 380319 bytes; the new one is 380755 bytes. The updated distribution can be retrieved from: utzoo!~/dtr/cnews.Z, utgpu!/usr/spool/uucppublic/cnews.Z, and uunet!~/news/cnews.Z by uucp, also known as uunet.uu.net:~ftp/news/cnews.Z by ftp. The copy on neat.ai.toronto.edu for ftp will be updated when neat.ai comes up after its latest disastrous crash. The copy on radio.astro.toronto.edu for ftp should be updated soon. 1. relay/mkpdir couldn't invoke itself because it was not found by its own PATH. Jean-Francois Lamy reported this one. 2. relaynews dumped core from not invalidating the last-newsgroup cache in active.c. This was found thanks to Mark Moraes's malloc. 3. control messages always got the default environment variables, even on a test system, because control.c used standard() to clear the environment. Now it uses closeall(1) instead since PATH and IFS are set at start up. The plain diffs are just 34 lines in total; they appear first and equivalent context diffs follow them. --- relay/aux/mkpdir --- 7c7 < PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH # must include this file's dir. --- > PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # must include this file's dir. --- relay/control.c --- 173,174c173,174 < * Enforce at least minimal security: standardise the environment, < * including PATH and IFS using standard(), a local addition to libc; --- > * Enforce at least minimal security: the environment was standardised at > * startup, including PATH and IFS; close non-standard file descriptors; 184c184 < standard(); /* close most files, etc. */ --- > closeall(1); --- relay/active.c --- 36a37,40 > static struct lastngcache { > char *lnc_ng; /* newsgroup name */ > char *lnc_line; /* matching active file line */ > } lnc = { NULL, NULL }; 50,53d53 < static struct lastngcache { < char *lnc_ng; /* newsgroup name */ < char *lnc_line; /* matching active file line */ < } lnc = { NULL, NULL }; 135c135,136 < * Write back to disk the active file cache, if any. --- > * Write back to disk the active file cache, if any, and flush the > * last-newsgroup-cache, since it refers to the (now invalid) active file cache. 142a144 > lnc.lnc_ng = lnc.lnc_line = NULL; *** relay/active.c.old Mon Jun 12 04:12:47 1989 --- relay/active.c Mon Jun 12 04:12:49 1989 *************** *** 34,39 char actrelnm[] = "active"; static FILE *actfp = NULL; /* * return a pointer to the active file entry for ng --- 34,43 ----- char actrelnm[] = "active"; static FILE *actfp = NULL; + static struct lastngcache { + char *lnc_ng; /* newsgroup name */ + char *lnc_line; /* matching active file line */ + } lnc = { NULL, NULL }; /* * return a pointer to the active file entry for ng *************** *** 47,56 { register char *ngline, *ng, *flag; register int loopbreak = 100; - static struct lastngcache { - char *lnc_ng; /* newsgroup name */ - char *lnc_line; /* matching active file line */ - } lnc = { NULL, NULL }; if (lnc.lnc_ng != NULL && STREQ(lnc.lnc_ng, ang)) return lnc.lnc_line; --- 51,56 ----- { register char *ngline, *ng, *flag; register int loopbreak = 100; if (lnc.lnc_ng != NULL && STREQ(lnc.lnc_ng, ang)) return lnc.lnc_line; *************** *** 132,138 } /* ! * Write back to disk the active file cache, if any. */ statust actsync() --- 132,139 ----- } /* ! * Write back to disk the active file cache, if any, and flush the ! * last-newsgroup-cache, since it refers to the (now invalid) active file cache. */ statust actsync() *************** *** 140,145 register statust status = ST_OKAY; if (actfp != NULL) { status |= actfsync(actfp); if (nfclose(actfp) == EOF || status != ST_OKAY) { warning("error writing `%s'", ctlfile(actrelnm)); --- 141,147 ----- register statust status = ST_OKAY; if (actfp != NULL) { + lnc.lnc_ng = lnc.lnc_line = NULL; status |= actfsync(actfp); if (nfclose(actfp) == EOF || status != ST_OKAY) { warning("error writing `%s'", ctlfile(actrelnm)); *** relay/control.c.old Mon Jun 12 05:08:34 1989 --- relay/control.c Mon Jun 12 05:08:34 1989 *************** *** 170,177 * runctlmsg is called from a child of relaynews, so it must always * call _exit() rather than exit() to avoid flushing stdio buffers. * ! * Enforce at least minimal security: standardise the environment, ! * including PATH and IFS using standard(), a local addition to libc; * reject shell metacharacters in ctlcmd. */ STATIC void --- 170,177 ----- * runctlmsg is called from a child of relaynews, so it must always * call _exit() rather than exit() to avoid flushing stdio buffers. * ! * Enforce at least minimal security: the environment was standardised at ! * startup, including PATH and IFS; close non-standard file descriptors; * reject shell metacharacters in ctlcmd. */ STATIC void *************** *** 181,187 register char *cmd; register int cmdstat; ! standard(); /* close most files, etc. */ if (!safecmd(ctlcmd)) { (void) fprintf(stderr, "%s: control `%s' looks unsafe to execute\n", progname, ctlcmd); --- 181,187 ----- register char *cmd; register int cmdstat; ! closeall(1); if (!safecmd(ctlcmd)) { (void) fprintf(stderr, "%s: control `%s' looks unsafe to execute\n", progname, ctlcmd); *** relay/aux/mkpdir.old Mon Jun 12 21:07:27 1989 --- relay/aux/mkpdir Mon Jun 12 21:07:28 1989 *************** *** 4,10 # =()<. ${NEWSCONFIG-@@}>()= . ${NEWSCONFIG-/usr/lib/news/bin/config} export NEWSCTL NEWSBIN NEWSARTS ! PATH=$NEWSCTL/bin:$NEWSBIN:$NEWSPATH ; export PATH # must include this file's dir. umask $NEWSUMASK --- 4,10 ----- # =()<. ${NEWSCONFIG-@@}>()= . ${NEWSCONFIG-/usr/lib/news/bin/config} export NEWSCTL NEWSBIN NEWSARTS ! PATH=$NEWSCTL/bin:$NEWSBIN/relay:$NEWSBIN:$NEWSPATH ; export PATH # must include this file's dir. umask $NEWSUMASK -- Geoff Collyer utzoo!utstat!geoff, geoff@utstat.toronto.edu ``... skill such as yours is evidence of a misspent youth.'' - Herbert Spencer