Date: Wed, 19 Mar 2003 08:00:22 -0800 (PST) From: Mike Makonnen <mtm@identd.net> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/50118: calendar(1) dumps core if there is ./calendar/ Message-ID: <200303191600.h2JG0Mgk008875@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/50118; it has been noted by GNATS. From: Mike Makonnen <mtm@identd.net> To: Kimura Fuyuki <fuyuki@hadaly.org> Cc: FreeBSD-gnats-submit@FreeBSD.ORG, Mark Murray <mark@grondar.org> Subject: Re: bin/50118: calendar(1) dumps core if there is ./calendar/ Date: Wed, 19 Mar 2003 10:51:16 -0500 On Wed, 19 Mar 2003 17:13:45 +0900 Kimura Fuyuki <fuyuki@hadaly.org> wrote: > > >Number: 50118 > >Category: bin > >Synopsis: calendar(1) dumps core if there is ./calendar/ > >Confidential: no > >Severity: non-critical > >Priority: low > >Responsible: freebsd-bugs > >State: open > >Originator: Kimura Fuyuki > >Release: FreeBSD 5.0-RELEASE-p4 i386 > System: FreeBSD hadaly.dyndns.org 5.0-RELEASE-p4 FreeBSD 5.0-RELEASE-p4 #2: > Fri Mar 7 13:26:51 JST 2003 root@hadaly.dyndns.org:/.2/obj/usr/src/sys/NS i386 > > > > >Description: > calendar(1) dumps core if there is a directory named "calendar" in the > current working directory. > > >How-To-Repeat: > $ calendar > calendar: no calendar file: ``calendar'' > $ mkdir calendar > $ calendar > cpp: Internal error: Segmentation fault (program tradcpp0) > Please submit a full bug report. > See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions. > > >Fix: > Need some stat(2)s, e.g: > > http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/calendar/io.c?rev=1.22&content-type=text/x-cvsweb-markup > > But `f' mode for freopen looks nice for me: > > http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/calendar/calendar.c?rev=1.27&content-type=text/x-cvsweb-markup We don't support the 'f' mode and since it's non-standard I don't know if it has a chance of making it in. However, stat(2) will also work just fine, as you pointed out. Patch attached. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9 A3AA DAE1 E2AF DBCC 68B9 Index: usr.bin/calendar/io.c =================================================================== RCS file: /home/ncvs/src/usr.bin/calendar/io.c,v retrieving revision 1.19 diff -u -r1.19 io.c --- usr.bin/calendar/io.c 28 Jul 2002 13:46:09 -0000 1.19 +++ usr.bin/calendar/io.c 19 Mar 2003 15:42:58 -0000 @@ -241,20 +241,25 @@ struct stat sbuf; /* open up calendar file as stdin */ - if (!freopen(calendarFile, "r", stdin)) { + if (!freopen(calendarFile, "r", stdin) || + stat(calendarFile, &sbuf) == -1 || !S_ISREG(sbuf.st_mode)) { if (doall) { if (chdir(calendarHomes[0]) != 0) return (NULL); if (stat(calendarNoMail, &sbuf) == 0) return (NULL); - if (!freopen(calendarFile, "r", stdin)) + if (!freopen(calendarFile, "r", stdin) || + stat(calendarFile, &sbuf) == -1 || + !S_ISREG(sbuf.st_mode)) return (NULL); } else { chdir(getenv("HOME")); for (found = i = 0; i < sizeof(calendarHomes) / sizeof(calendarHomes[0]); i++) if (chdir(calendarHomes[i]) == 0 && - freopen(calendarFile, "r", stdin)) { + freopen(calendarFile, "r", stdin) && + stat(calendarFile, &sbuf) == 0 && + S_ISREG(sbuf.st_mode)) { found = 1; break; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200303191600.h2JG0Mgk008875>