Date: Sun, 12 Sep 2004 16:15:41 +0200 (CEST) From: Dan Lukes <dan@obluda.cz> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/71651: [PATCH] cron may attept to close unopened file Message-ID: <200409121415.i8CEFffA009717@kulesh.obluda.cz> Resent-Message-ID: <200409121420.i8CEKMsq089662@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 71651 >Category: bin >Synopsis: [PATCH] cron may attept to close unopened file >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Sep 12 14:20:22 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 5.3-BETA3 i386 >Organization: Obludarium >Environment: System: FreeBSD kulesh.obluda.cz 5.3-BETA3 FreeBSD 5.3-BETA3 #8: Sun Sep 5 07:06:40 CEST 2004 dan@kulesh.obluda.cz:/usr/obj/usr/src/sys/Dan i386 usr.sbin/cron/lib/misc.c,v 1.11 2002/08/04 04:32:27 tjr usr.sbin/cron/cron/cron.c,v 1.15 2004/05/16 19:29:33 yar usr.sbin/cron/cron/do_command.c,v 1.22 2004/05/16 19:29:33 yar >Description: usr.sbin/cron/lib/misc.c:413: warning: 'deny' might be used uninitialized in this function It's sign of true bug. When fopen of ALLOW_FILE fail for other than ENOENT reason, then "goto out" apply then 'if (deny)' is evaluated and 'fclose(deny)' may be called athought 'deny' is uninitialized variable. I want to eliminate the following warning also, but they are "false-positives" only ...: usr.sbin/cron/cron/cron.c:165: warning: 'otzminute' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzhour' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzdom' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzmonth' might be used uninitialized in this function usr.sbin/cron/cron/cron.c:165: warning: 'otzdow' might be used uninitialized in this function usr.sbin/cron/cron/do_command.c:388: warning: 'mail' might be used uninitialized in this function >How-To-Repeat: N/A >Fix: *** usr.sbin/cron/lib/misc.c.ORIG Wed Aug 7 00:03:16 2002 --- usr.sbin/cron/lib/misc.c Sun Sep 12 15:52:00 2004 *************** *** 419,425 **** if ((allow = fopen(ALLOW_FILE, "r")) == NULL && errno != ENOENT) goto out; if ((deny = fopen(DENY_FILE, "r")) == NULL && errno != ENOENT) ! goto out; Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny)) #else allow = NULL; --- 419,425 ---- if ((allow = fopen(ALLOW_FILE, "r")) == NULL && errno != ENOENT) goto out; if ((deny = fopen(DENY_FILE, "r")) == NULL && errno != ENOENT) ! goto out1; Debug(DMISC, ("allow/deny enabled, %d/%d\n", !!allow, !!deny)) #else allow = NULL; *************** *** 437,446 **** isallowed = TRUE; #endif } out: if (allow) fclose(allow); - if (deny) - fclose(deny); return (isallowed); } --- 437,446 ---- isallowed = TRUE; #endif } + out1: if (deny) + fclose(deny); out: if (allow) fclose(allow); return (isallowed); } *** usr.sbin/cron/cron/cron.c.ORIG Tue May 18 22:20:13 2004 --- usr.sbin/cron/cron/cron.c Sun Sep 12 16:00:03 2004 *************** *** 162,168 **** static time_t diff = 0, /* time difference in seconds from the last offset change */ difflimit = 0; /* end point for the time zone correction */ struct tm otztm; /* time in the old time zone */ ! int otzminute, otzhour, otzdom, otzmonth, otzdow; register struct tm *tm = localtime(&TargetTime); register int minute, hour, dom, month, dow; register user *u; --- 162,170 ---- static time_t diff = 0, /* time difference in seconds from the last offset change */ difflimit = 0; /* end point for the time zone correction */ struct tm otztm; /* time in the old time zone */ ! int otzminute = otzminute, /* "init" to avoid "might be used uninitialized" warning */ ! otzhour = otzhour, otzdom = otzdom, ! otzmonth = otzmonth, otzdow = otzmonth; register struct tm *tm = localtime(&TargetTime); register int minute, hour, dom, month, dow; register user *u; *** usr.sbin/cron/cron/do_command.c.ORIG Tue May 18 22:20:13 2004 --- usr.sbin/cron/cron/do_command.c Sun Sep 12 16:04:42 2004 *************** *** 385,391 **** ch = getc(in); if (ch != EOF) { ! register FILE *mail; register int bytes = 1; int status = 0; --- 385,391 ---- ch = getc(in); if (ch != EOF) { ! register FILE *mail = mail; /* "init" to avoid "might be used uninitialized" warning */ register int bytes = 1; int status = 0; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409121415.i8CEFffA009717>